DOS Games Message Board
DOS Games Discussion
A message board to talk about DOS games, get help, and find old games.
Do NOT post warez or abandonware requests please
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Visual Basic game help

 
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation
Author Message
Jeff
Member
Member


Offline
Joined: 07 Aug 2003
Posts: 49

PostPosted: Thu Oct 30, 2003 5:07 pm     Post subject: Visual Basic game help Reply with quote

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.
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3945
Location: Ontario Canada

PostPosted: Thu Oct 30, 2003 10:50 pm     Post subject: Reply with quote

Code:
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:
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-
Back to top
Splodginator
Way too much free time
Way too much free time


Offline
Joined: 23 Apr 2003
Posts: 558
Location: Nowhere.

PostPosted: Fri Oct 31, 2003 12:46 am     Post subject: Reply with quote

Add "\n" or (I think) "\n\l" or "\n\r", I forget which one is Windows.
Back to top
Jeff
Member
Member


Offline
Joined: 07 Aug 2003
Posts: 49

PostPosted: Fri Oct 31, 2003 4:55 pm     Post subject: Reply with quote

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.
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3945
Location: Ontario Canada

PostPosted: Fri Oct 31, 2003 10:22 pm     Post subject: Reply with quote

to open multiple files, simply go

Code:
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-
Back to top
Jeff
Member
Member


Offline
Joined: 07 Aug 2003
Posts: 49

PostPosted: Sat Nov 01, 2003 11:02 am     Post subject: Reply with quote

k thanks
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3945
Location: Ontario Canada

PostPosted: Sat Nov 01, 2003 10:09 pm     Post subject: Reply with quote

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

-Richard-
Back to top
AngryDwarf
Member
Member


Offline
Joined: 22 Sep 2004
Posts: 11
Location: Australia

PostPosted: Wed Sep 22, 2004 2:31 am     Post subject: Reply with quote

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
Back to top
Jeff
Member
Member


Offline
Joined: 07 Aug 2003
Posts: 49

PostPosted: Sun Sep 26, 2004 10:35 pm     Post subject: Reply with quote

Vb is Vbclrf, I think
Back to top
barok_unlogged
Guest






PostPosted: Fri Oct 01, 2004 12:50 am     Post subject: Reply with quote

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.
Back to top
wardrich
"Some Troll"


Offline
Joined: 14 Sep 2002
Posts: 3945
Location: Ontario Canada

PostPosted: Fri Oct 01, 2004 10:04 pm     Post subject: Reply with quote

that's why you close it before another one tries to open it Wink
Back to top
barok_unlogged
Guest






PostPosted: Sun Oct 03, 2004 12:36 pm     Post subject: Reply with quote

freefile is da way to go. It just saves some trouble. Shit-Eating Grin
Back to top
Display posts from previous:   
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> Game Creation All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group and Ask an Expert
Also powered by Darren and the other admin and mods' hard work! ;)