Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

VB .NET Help

l34f3rl34f3r Posts: 1Member
Hi I'm new to programming so I was hoping you guys could help me out, what I want to do is I want to read text from a txt file and then output
it to a griline on a form which would have a cancel and save button. What I
got so far is a bit of code that would read the text from the txt file but
I'm not sure how I would output that onto the form. Any ideas? Any help
would be greatly appreciated as I'm a begginner at this.

This is the code I got so far...

----------------------------------------------------------
'Reading from text file

Dim oFile As System.IO.File

Dim oRead As System.IO.StreamReader

oRead = oFile.OpenText("C:input.txt")

Dim LineIn As String

While oRead.Peek <> -1

LineIn = oRead.ReadLine()

End While

oRead.Close()

---------------------------------------------------------------------------------------

Comments

  • DrMartenDrMarten Posts: 748Member
    : Hi I'm new to programming so I was hoping you guys could help me out, what I want to do is I want to read text from a txt file and then output
    : it to a griline on a form which would have a cancel and save button. What I
    : got so far is a bit of code that would read the text from the txt file but
    : I'm not sure how I would output that onto the form. Any ideas? Any help
    : would be greatly appreciated as I'm a begginner at this.
    :
    : This is the code I got so far...
    :
    : ----------------------------------------------------------
    : 'Reading from text file
    :
    : Dim oFile As System.IO.File
    :
    : Dim oRead As System.IO.StreamReader
    :
    : oRead = oFile.OpenText("C:input.txt")
    :
    : Dim LineIn As String
    :
    : While oRead.Peek <> -1
    :
    : LineIn = oRead.ReadLine()
    :
    : End While
    :
    : oRead.Close()
    ______________________________________________________________________

    Hi,

    Provided the text file isn't very big why not add the following line just before your END WHILE.>>
    [code]
    textbox1.appendtext(LineIn & vbCrLf)
    [/code]

    Just make sure you add a textbox to your project, for it's properties set MULTILINE=TRUE then drag it larger vertically.
    You could ensure the default value is "" and that the scrollbars property has VERTICAL only set. :-)

    Use STREAMWRITER to SAVE. I'm sure you know that.
    [code]
    Dim outString As String
    outString=textbox1.text
    'Then write the string to your outFile.
    [/code]


    Regards,

    Dr M.

    P.S. A textbox has a limit on the amount of text it can hold.
    If your file text is bigger then not all of the text will be shown.

    I don't know if the amount of text that a textbox can hold, can be altered or not.

Sign In or Register to comment.