|
-
December 20th, 2002, 05:49 PM
#1
How can I read this text file?
Hi all,
I have a text file (.txt) with data in for a game. There is different data on each line a bit like this:
Level 1
Data A
Data B
Data C
Level 2
Data A
Data B
Data C
I have a button (CmdRead) on my form which I want to be able to click and for Data A to go into text box A, Data B into text box B and so on, but only, for a specific level. E.g. all data from level 1 or all data from level 2.
Any info on how I can do this?? Thanks!
Mark
-
December 20th, 2002, 08:13 PM
#2
Code:
Option Explicit
Sub cmdRead_Click()
Dim TxStrm As String
Dim DesiredLevel As String
DesiredLevel = MsgBox("Enter Level Number")
If DesiredLevel = "" Then
Exit Sub
End If
DesiredLevel = "Level " & Trim(DesiredLevel)
Open "C:\Myfile.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, TxStrm
If DesiredLevel = Trim(TxStrm) Then
Line Input #1, TxStrm
txBox1.Text = Trim(TxStrm)
Line Input #1, TxStrm
txBox2.Text = Trim(TxStrm)
Line Input #1, TxStrm
txBox3.Text = Trim(TxStrm)
Exit Do
End If
Loop
Close #1
End Sub
Marketing our skills - please participate in the survey and share your insights
-
-
December 21st, 2002, 07:28 AM
#3
Code works fine... Thanks.
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|