31
Mar

My assignment is to create a game that you type your guess from 1 to 100 and computer tells you if you get the number,or too high or guess was too low. I made the game and everything words, except, the computer only give you 1 chance to correctly guess the number and then changes the number. I know I need a loop in their Help Me This is the Code I have so far

Private Sub Command1_Click()

Dim intNum As Integer

Randomize

intNum = (Rnd * 100)

If txtUser = intNum Then

MsgBox "You Did It. The number was " & intNum

ElseIf txtUser > intNum Then

MsgBox "Your Number is high " & intNum

ElseIf txtUser < intNum Then

MsgBox "Your Number is low " & intNum

End If

End Sub


Answer:
Dim intNum As Integer

Dim attemptNum As Integer

Private Sub Command1_Click()

If attemptNum < 10 Then

If txtUser.Text = intNum Then

MsgBox "You Did It. The number was " & intNum

ElseIf txtUser > intNum Then

MsgBox "Your Number is high " & intNum

ElseIf txtUser < intNum Then

MsgBox "Your Number is low " & intNum

End If

End If

attemptNum = attemptNum 1

End Sub

Private Sub Form_Load()

Randomize

intNum = (Rnd * 100)

End Sub

Hope this helps. The random number has to be worked out when the program starts, because before you were having a different number worked out when you pressed the button.


Answer:
If you are still stuck may be you can contact a VB expert live at website like http://askexpert.info/ .

Book Mark it-> del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Netscape | Yahoo | BlinkList

This entry was posted on Monday, March 31st, 2008 at 4:40 am and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or TrackBack URI from your own site.

Leave a reply

Name (*)
Mail (*)
URI
Comment