Reading data from text file
I need help, me and my friend are working on a simple game and we want it to load the character's info from the text file.
for example:
Private Sub Form_Load()
CharName.Text = (Load from line 1 of text file)
CharLevel.Text = (Load from line 2 of text file)
If TextFile Doesn't Exist Then
MsgBox "No character files could be loaded, you need to make a new character"
End If
End Sub
and so on, also, I need to know how to save this data to a text file (for creating a new character)
And I need it so if there's no such file, it will tell the user that he/she needs to create a character.
Thanks,
Kalo93
Re: Reading data from text file
You may want to start in the FAQs section of the forums. Browse around and specifically play with the "Files" section.
Re: Reading data from text file
Re: Reading data from text file
None of them help? So you already know how to read and write a file?
Then you may want to show us what you have so far and we can provide help on that.
Re: Reading data from text file
None of them tell me how to read more than one line, all it's telling me is how to read the first line of the text file.
I don't want that >_>
Re: Reading data from text file
Quote:
Originally Posted by
kalo93
None of them tell me how to read more than one line, all it's telling me is how to read the first line of the text file.
I don't want that >_>
You may have not spent enough time in the FAQ section. Recommend looking specifically at "How to do basic manipulation of text files [Tutorial]", within the Files section of the FAQs.
Re: Reading data from text file
I have this so far but it displays 10 in the charname
vb Code:
Private Sub Form_Load()
Dim fileID As Long
fileID = FreeFile()
Open "char1.txt" For Input Lock Write As #fileID
Dim line As String
Do While (Not EOF(fileID))
Line Input #fileID, line
name1.Caption = line
lvl1.Caption = line2
Loop
Close #fileID
End Sub