1.

Solve : Making a game..sorta?

Answer»

I had a few questions about Virtual Basic and was WONDERING if anyone could help.... To begin with I have two forms..One called children and the other called game.Game has three option buttons on it and so does game. both of them also have a label.I also have a command box.The label would be where I put the question and the option buttons where I put the answers.the command box is called answer...I want to make it so when I click the answer Paris it will log my answer and open the other form children..I TRIED doing it but I didn't know the extension for the option buttons,to link a form, or a label...I do not understand how to do this..PLEASE help..thank YouIn the click event for the Paris option, you could Unload Me and Children.Show.

There are many ways to do this THOUGH. When Me is unloaded in will fire the Unload Event for the form and you could do some processing there. If you want both forms visible, do not unload anything, but you would have to account for which form has focus and code accordingly.

Note: Me refers to the active form.

Good luck. Whenever I push play it gives me an error saying "Compil eerror: Expected Variable or Funtion."
The line Private Sub Paris_Click() is in Yellow.This is the very first line.Under that I have Unload Game And children.Show..I don't know the extension for game(which is a form) or Paris (which is a choice) I also needed to know how to log the results so they can be displayed in the end..Thanks..Well I figured out how to make it link but now I need to know how to make my results show in the ending....I messed with the msgbox but I still don't know how..Thanks for the other problem..The easiest way is to store your responses in an array and dump the array to a msgbox or another form when you want to display them. You could also use a FILE or database to hold your responses, but I/O is not one of VB's strong points and a DB is overkill.

If you do decide to use a file, define a reference to the Microsoft Scripting Runtime (Project-->References) and use the FileSystemObject to do your reads and writes.

Good luck. Could you please go into a little bit more detail about the two ways..I wated it to store the USERS answers and then display them back...According to what they pick..Thanks..Sorry Im new at thisA forum may not be the best way to learn VB. A general overview would be:

1. Create a public array
2. Have each event handler update the array with the question number and the answer
3. Iterate the array to a msgbox at the end

OR

1. Create a public array
2. Create a pubic sub to update the array
3. Have each event handler pass the Q&A to the sub, which updates the array (all the code for the array update is isolated)
4. Iterate the array to a msgbox at the end

If this is a multiplayer game, you would also have to have an array for each user or make room in your array for a userid.

An array is the best way to go. Using a file adds complexity and would only be needed if your concerned about a power failure.

I made a group of arrays like this....
Dim Where(3) As String

Where(0) = "You are going to goto Switzerland for your honeymoon with"
Where(1) = "You are going to goto Hawaii for your honeymoon with"
Where(2) = "You are going to goto Paris for your honeymoon with"

Dim WithWho(6) As String
WithWho(0) = "Muqdisa and have "
WithWho(1) = "Marina and have"
WithWho(2) = "Sadaf and have"
WithWho(3) = "Suman and have"
WithWho(4) = "Balqis and have"
WithWho(5) = "Ruccsana and have"

Dim Children(3) As String
Children(0) = "1 child :) ENJOY!"
Children(1) = "2 children :) ENJOY!"
Children(2) = "3 children :) ENJOY!"


I have 4 forms.... Where, WithWho,Children,and Results
I put the above Array in Results...In the form Where there are three option button(Switzerland,Hawaii,Paris) In the Form WithWho there are numbers 1-6  done by option buttons.. 1-6 are peoples names...My last form is children which are option buttons 1-3..How would I make this program so that if someone clikcs on Paris from the form Where, 1 from the form WithWho, and 1 from the form children it will display You are going to goto Paris for your honeymoon with Muqdisa and have 1 child :) ENJOY!Define RESULTS as an array. In the _click event for each button, push the answer into the array. (ie. If Paris is chosen for question 1, then result(0) = "Paris", if Hawaii is chosen then result(0) = "Hawaii". If question 2 is answered with "Muqdisa" then that goes into result(1).

Once all the questions are answered, you can build the output, which is mostly a literal.

"You are going to goto " result(0) & " for your honeymoon with " & result(1) & " and have " & result(2) & " child."

The literal could be dumped into a label on the form, a msgbox, a file, sent across the net. Your choices are limited only by your imagination.

Good luck.



Discussion

No Comment Found