Guessing Game

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2008
Posts: 10
Reputation: LottaBajan2 is an unknown quantity at this point 
Solved Threads: 0
LottaBajan2 LottaBajan2 is offline Offline
Newbie Poster

Guessing Game

 
0
  #1
Oct 4th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 305
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 25
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Guessing Game

 
0
  #2
Oct 4th, 2008
Did you set upperbound and lowerbound to anything?

  1. Private Sub cmdGuess_Click()
  2. Me.Text2.Text = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
  3.  
  4. End Sub
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 10
Reputation: LottaBajan2 is an unknown quantity at this point 
Solved Threads: 0
LottaBajan2 LottaBajan2 is offline Offline
Newbie Poster

Re: Guessing Game

 
0
  #3
Oct 5th, 2008
Please be patient with me as i am a novice at this. No I did not set the upper or lower bounds to anything. Can you explain how to do this?
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 305
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 25
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Guessing Game

 
0
  #4
Oct 5th, 2008
Here is some code that will hopefully point you in the direction you are trying to go:

  1. Private Sub cmdGuess_Click()
  2.  
  3. dim upperbound as integer
  4. dim lowerbound as integer
  5.  
  6. upperbound = 100
  7. lowerbound = 10
  8.  
  9. Me.Text2.Text = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
  10.  
  11. End Sub
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 10
Reputation: LottaBajan2 is an unknown quantity at this point 
Solved Threads: 0
LottaBajan2 LottaBajan2 is offline Offline
Newbie Poster

Re: Guessing Game

 
0
  #5
Oct 5th, 2008
Thank you it worked somewhat but i have to solve some other problems. Can i get bact to you if more help is needed
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 305
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 25
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Guessing Game

 
0
  #6
Oct 5th, 2008
Of course; I'd be happy to help whenever I can!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 10
Reputation: LottaBajan2 is an unknown quantity at this point 
Solved Threads: 0
LottaBajan2 LottaBajan2 is offline Offline
Newbie Poster

Re: Guessing Game

 
0
  #7
Oct 5th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 10
Reputation: LottaBajan2 is an unknown quantity at this point 
Solved Threads: 0
LottaBajan2 LottaBajan2 is offline Offline
Newbie Poster

Re: Guessing Game

 
0
  #8
Oct 5th, 2008
How do I code my keypad?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 10
Reputation: LottaBajan2 is an unknown quantity at this point 
Solved Threads: 0
LottaBajan2 LottaBajan2 is offline Offline
Newbie Poster

Re: Guessing Game

 
0
  #9
Oct 8th, 2008
Hello,

Nobody seems to be answering my question is that because I really have no clue about what I am doing? I am feeling really pressured here because I really have no clue and i would really like to learn this!!!
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 305
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 25
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Guessing Game

 
0
  #10
Oct 8th, 2008
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?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC