zinaurbanski
June 19th, 2001, 09:50 PM
I am working on my homework to create Guess The Nubmer game and I am having ahard time programming. Can some help me please??
Thanks
zurbanski@mediaone.net
Thanks
zurbanski@mediaone.net
|
Click to See Complete Forum and Search --> : Guess The Number Game zinaurbanski June 19th, 2001, 09:50 PM I am working on my homework to create Guess The Nubmer game and I am having ahard time programming. Can some help me please?? Thanks zurbanski@mediaone.net Kdev June 20th, 2001, 08:10 AM I'm not sure what game you are thinking of but I will give a go at it. If you would like to randomly pick a number from 1 to 100 and have the user try to guess this number with every guess telling the user whether the number is higher or lower than the guessed number you would go about it like this: option Explicit private nAnswer as Integer private Sub Command1_Click() static nTries as Integer If IsNumeric(Text1.Text) then If Text1.Text > 100 Or Text1.Text < 1 then MsgBox "Number out of range. Must be between 1-100." ElseIf Int(Text1.Text) <> Text1.Text then MsgBox "Only enter integers" else nTries = nTries + 1 If Text1.Text = nAnswer then MsgBox "You got it!" & vbNewLine & _ "It took you " & nTries & " tries." nTries = 0 Form_Load ElseIf Text1.Text > nAnswer then MsgBox "Lower" ElseIf Text1.Text < nAnswer then MsgBox "Higher" End If End If else MsgBox "Not a number!" End If End Sub private Sub Form_Load() Randomize nAnswer = (Rnd * 100) + 1 End Sub -K codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |