Visual Basic game help

Discuss popular GCS tools like ZZT, Megazeux and Adventure Game Studio, as well as programming and other topics related to game design.
Post Reply
Jeff
Member
Member
Posts: 49
Joined: Thu Aug 07, 2003 2:49 pm

Visual Basic game help

Post by Jeff »

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.
<A href = "http://dosstuff.cjb.net" >Free Dos Stuff</a>
User avatar
wardrich
"Some Troll"
Posts: 3940
Joined: Sat Sep 14, 2002 9:08 pm
Location: Ontario Canada

Post by wardrich »

Code: Select all

Private Sub &#91;event name&#93;&#40;&#41;

Dim strNames As String
Dim strNames2 As String


Open "&#91;filename.rtf&#93;" For Input As #1
While Not &#40;EOF&#40;1&#41;&#41;

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 &#91;event name&#93;&#40;&#41;

Dim strNames As String
Dim strNames2 As String


Open "&#91;filename.rtf&#93;" For Input As #1
While Not &#40;EOF&#40;1&#41;&#41;  
'While not EOF means WHILE NOT at the END OF THE FILE...

Input #1, string1
'In your case, string1 should be 1&#41;Jeff
Input #1, string2
'In your case, string2 should be 2&#41;Jeff
input #1, string3
'In your case, string3 should be 3&#41;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-
Splodginator
Way too much free time
Way too much free time
Posts: 558
Joined: Wed Apr 23, 2003 10:28 pm
Location: Nowhere.

Post by Splodginator »

Add "\n" or (I think) "\n\l" or "\n\r", I forget which one is Windows.
Jeff
Member
Member
Posts: 49
Joined: Thu Aug 07, 2003 2:49 pm

Post by Jeff »

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>
User avatar
wardrich
"Some Troll"
Posts: 3940
Joined: Sat Sep 14, 2002 9:08 pm
Location: Ontario Canada

Post by wardrich »

to open multiple files, simply go

Code: Select all

Open "&#91;filename.rtf&#93;" For Input As #1 
Open "&#91;filename.rtf&#93;" For Input As #2
Open "&#91;filename.rtf&#93;" For Input As #3
While Not &#40;EOF&#40;1&#41;&#41; 

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-
Jeff
Member
Member
Posts: 49
Joined: Thu Aug 07, 2003 2:49 pm

Post by Jeff »

k thanks
<A href = "http://dosstuff.cjb.net" >Free Dos Stuff</a>
User avatar
wardrich
"Some Troll"
Posts: 3940
Joined: Sat Sep 14, 2002 9:08 pm
Location: Ontario Canada

Post by wardrich »

no problem. Just keep posting in here if you have any VB problems. I <i>should</i> be able to help you with it.

-Richard-
User avatar
AngryDwarf
Member
Member
Posts: 11
Joined: Wed Sep 22, 2004 2:10 am
Location: Australia

Post by AngryDwarf »

Splodginator wrote:Add "\n" or (I think) "\n\l" or "\n\r", I forget which one is Windows.
Im pretty sure thats only languages such as C,C++,C#,etc
<marquee>veni vidi rapui</marquee>
Jeff
Member
Member
Posts: 49
Joined: Thu Aug 07, 2003 2:49 pm

Post by Jeff »

Vb is Vbclrf, I think
<A href = "http://dosstuff.cjb.net" >Free Dos Stuff</a>
barok_unlogged

Post by barok_unlogged »

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.
User avatar
wardrich
"Some Troll"
Posts: 3940
Joined: Sat Sep 14, 2002 9:08 pm
Location: Ontario Canada

Post by wardrich »

that's why you close it before another one tries to open it ;)
barok_unlogged

Post by barok_unlogged »

freefile is da way to go. It just saves some trouble. :D
Post Reply