|
-
Oct 29th, 2009, 03:12 PM
#1
Thread Starter
Lively Member
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
-
Oct 29th, 2009, 03:26 PM
#2
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.
-
Oct 29th, 2009, 03:32 PM
#3
Thread Starter
Lively Member
Re: Reading data from text file
-
Oct 29th, 2009, 03:35 PM
#4
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.
-
Oct 29th, 2009, 03:38 PM
#5
Thread Starter
Lively Member
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 >_>
-
Oct 29th, 2009, 03:41 PM
#6
Re: Reading data from text file
 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.
-
Oct 29th, 2009, 03:49 PM
#7
Thread Starter
Lively Member
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
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
|