| | |
Guessing Game
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Oct 2008
Posts: 10
Reputation:
Solved Threads: 0
Hi,
I am very new to visual basic 6.0 and I am trying to create a guessing game in visual basic where the computer generates three numbers and the player tries to guess what they are. I am now starting the basics and I have the GUI sorted out but the code is giving me a bit of problem. When the GUESS button is pressed the computer is supposed to generate a random 3 digit number and they must appear as ***. This is what i have so far and it does not work.
Private Sub cmdGuess_Click()
Me.Text2.Text = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
End Sub
The player must then try to guess the three numbers by using a number pad press a button to see if they have won.
I am very new to visual basic 6.0 and I am trying to create a guessing game in visual basic where the computer generates three numbers and the player tries to guess what they are. I am now starting the basics and I have the GUI sorted out but the code is giving me a bit of problem. When the GUESS button is pressed the computer is supposed to generate a random 3 digit number and they must appear as ***. This is what i have so far and it does not work.
Private Sub cmdGuess_Click()
Me.Text2.Text = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
End Sub
The player must then try to guess the three numbers by using a number pad press a button to see if they have won.
Did you set upperbound and lowerbound to anything?
vb Syntax (Toggle Plain Text)
Private Sub cmdGuess_Click() Me.Text2.Text = Int((upperbound - lowerbound + 1) * Rnd + lowerbound) End Sub
Here is some code that will hopefully point you in the direction you are trying to go:
vb Syntax (Toggle Plain Text)
Private Sub cmdGuess_Click() dim upperbound as integer dim lowerbound as integer upperbound = 100 lowerbound = 10 Me.Text2.Text = Int((upperbound - lowerbound + 1) * Rnd + lowerbound) End Sub
•
•
Join Date: Oct 2008
Posts: 10
Reputation:
Solved Threads: 0
My numbers are being randomly generated by the computer but when i try to get my player to select 3 numbers one is being replaced by the other (in other words only one number is showing up) i know i need to do an if statement but cannot figure out how to code it. I know it needs to be something like this; if the player choses (for instance) 1 3 5 then store it and compare it to the randomly stored number. so should it be something like this?
if (num = 1) then
lbl.player.caption = 1
elseif (num = 2) then
lbl.player.caption = 2
I am choosing the numbers by a numbered key pad.
if (num = 1) then
lbl.player.caption = 1
elseif (num = 2) then
lbl.player.caption = 2
I am choosing the numbers by a numbered key pad.
Okay... as far as the first issue... you mention that the program picks three random numbers okay but that one is being replaced? It sounds like you are storing a different value in the variable. Do you have any code?
As far as the keypad, what are you trying to do with it? Are you trying to use the keypad to enter numbers in a textbox or are you trying to detect when a user presses one of the buttons on the keypad?
As far as the keypad, what are you trying to do with it? Are you trying to use the keypad to enter numbers in a textbox or are you trying to detect when a user presses one of the buttons on the keypad?
![]() |
Similar Threads
- How do i create a simple game using c++?? (C++)
- stuck with guessing game please help (C)
- GUI Python - A Guessing Game (Python)
- Guessing Game In C Help - High Score (C)
- guessing game program problem (C++)
- Number guessing game problem (C++)
- Number Guessing game problem (C++)
- 2D guessing game (Python)
Other Threads in the VB.NET Forum
- Previous Thread: SQL Error Display Event Form
- Next Thread: image processing in vb.net
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic binary bing button buttons center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel file-dialog firewall folder ftp google hardcopy image images insert isnumericfuntioncall listview login math memory mobile ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port print problemwithinstallation project reports" save savedialog searchbox serial soap sorting string table tcp temp text textbox timer toolbox trim update updown upload useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





