Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading from text file

Status
Not open for further replies.

Scouseman

Technical User
Mar 25, 2003
22
US
HI

I wonder if someone can help me. I am trying to read the following line from a text file.

200310,11:29:06,D03,LONG,3422

I am then trying to display the first 4 items as stings in a text box and the last item (3422) as an integer. Then if a new line appears in the text file I would like the text boxes to update. Can anybody tell me if this is possible?

Thanks for you time.

Scouseman :)

 
You could try using split function to load into an array then assign each text box and the integer individually to the different elements of the array. You'd have to use the open statement and line input to get the text out the file first of course.
 
Dim S1 as string, S2 as String, S3 as String, S4 as String
Dim I1 as Integer

Open "Filename" for input as #1
Do While Not EOF (1)
Get #1, S1, S2, S3, S4, I1
Loop
Close #1

The following will always display the last entry in the file.

Text1.text = S1 & S2 & S3 & S4 & I1

or using individual text boxes:

Text1,Text = S1
Text2.Text = S2
Text3.Text = S3
Text4.Text = S4
Text5.Text = I1

If you want to check for updates to the file automatically use a timer control.



Experience is something you don't get until just after you need it.
 
Thanks bigalbigal for the code, it was much appreciated, it works just fine

Scouseman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top