Dynadot โ€” .com Transfer

Need help in reading from a text file in VB

Spaceship Spaceship
Watch

mattonline

Established Member
Impact
2
i know this isn't complex and i've search around but can't find anything which works for me.

But i'm wondering how i could read from a text file.

i want to display the text into a vb 'text box'

assume the .txt file is loacated at c:text/text.txt

what would be the code i would need for this.

Thanks again
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
VB6 or VB.net ?
 
0
•••
vb6 - sorry should of stated this
 
0
•••
Something along these lines:

Assuming the file is C:\digi.txt and the textbox is named txt_output
Code:
Dim int_fh As Integer
Dim str_contents As String, str_file As String
int_fh = FreeFile

Open "C:\digi.txt" For Input As int_fh
Do While Not EOF(int_fh)
    Line Input #int_fh, str_contents
    Me.txt_output.SetFocus
    str_file = str_file & str_contents ' concatenate
Loop

Close #int_fh

Me.txt_output.Text = str_file
There are limits to the amount of text in a text box so you should use a RTFtextbox or similar for larger files.
 
0
•••
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back