Visual Basic game help
Visual Basic game help
Hi. I'm trying to make a game, and i need to know how to load a file to a rich text box and keep the line breaks.
This is how it is now:
1) Jeff 2) Jeff 3) DRM
This is how I want it to be:
1) Jeff
2) Jeff
3) DRM
Thanks in advance.
This is how it is now:
1) Jeff 2) Jeff 3) DRM
This is how I want it to be:
1) Jeff
2) Jeff
3) DRM
Thanks in advance.
<A href = "http://dosstuff.cjb.net" >Free Dos Stuff</a>
Code: Select all
Private Sub [event name]()
Dim strNames As String
Dim strNames2 As String
Open "[filename.rtf]" For Input As #1
While Not (EOF(1))
Input #1, string1
Input #1, string2
input #1, string3
Wend
Close #1
End Sub
In your case, here's basically what it should look like...
Code: Select all
Private Sub [event name]()
Dim strNames As String
Dim strNames2 As String
Open "[filename.rtf]" For Input As #1
While Not (EOF(1))
'While not EOF means WHILE NOT at the END OF THE FILE...
Input #1, string1
'In your case, string1 should be 1)Jeff
Input #1, string2
'In your case, string2 should be 2)Jeff
input #1, string3
'In your case, string3 should be 3)DRM
Wend
Close #1
End Sub
I think if you want the user to be able to click the choice and have it execute, your best choice would be to use a Listbox. Let me know if you need more help with this.
-Richard-
-
- Way too much free time
- Posts: 558
- Joined: Wed Apr 23, 2003 10:28 pm
- Location: Nowhere.
I want it to be more then one file. So they can export and inport their high scores. I'm using a Common Dialog to do this.
<A href = "http://dosstuff.cjb.net" >Free Dos Stuff</a>
to open multiple files, simply go
Just remeber to close each file that you open.
-Richard-
Code: Select all
Open "[filename.rtf]" For Input As #1
Open "[filename.rtf]" For Input As #2
Open "[filename.rtf]" For Input As #3
While Not (EOF(1))
Input #1, string1
Input #1, string2
input #1, string3
Wend
Close #1
Close #2
Close #3
End Sub
Just remeber to close each file that you open.
-Richard-
- AngryDwarf
- Member
- Posts: 11
- Joined: Wed Sep 22, 2004 2:10 am
- Location: Australia
it's bad practise to open files as #1 or #2 or #3. instead, dimension a variable for each open statement. right before open, you have this:
openvariable = FREEFILE
freefile will get the next open number, so if you have #1 being used by another open statment and you try to open another file as #1, the program will crash. by having openvariable = freefile, it should prevent crashing.
openvariable = FREEFILE
freefile will get the next open number, so if you have #1 being used by another open statment and you try to open another file as #1, the program will crash. by having openvariable = freefile, it should prevent crashing.