Valhalla Legends Forums Archive | Visual Basic Programming | Help...again

AuthorMessageTime
Reaper
[code]
Private Sub cmdGo_Click()
If txtBet.Text = "" Then
MsgBox ("Please place a bet")
Unload Me
frmPickANumber.Show
End If
lblAnswer.Caption = "And the number is..."
lblNumber.Caption = Rand(1, 25)
If txtNumber.Text = lblNumber.Caption Then
MsgBox ("Mega-Winner!! $500 has been sent to your account!")
frmAccount.lblWinning1.Caption = "$500"
frmAccount.lblWinning1.Enabled = False
End If
Else
MsgBox ("Ouch Sorry!")
frmAccount.lblWinning1.Caption = txtBet.Text
frmAccount.lblWinning1.FontStrikethru = True
End If
End Sub
[/code]

I want to make it so that if the guess is in range of the number by 5 it would give like $200 or something. Ex.  The random number is 15, if the person guessed 12, they're in range by 5, so they get some money.
I'm not sure how to go about this though?
December 22, 2004, 5:48 AM
HdxBmx27
[code]
If Val(txtNumber.Text) = Val(lblNumber.Caption)  then 'Right on the dot
ElseIf (Val(txtNumber.Text) <= Val(lblNumber.Caption) + 5) And (Val(txtNumber.Text) >= Val(lblNumber.Caption) - 5) Then '5 away
ElseIf (Val(txtNumber.Text) <= Val(lblNumber.Caption) + 10) And (Val(txtNumber.Text) >= Val(lblNumber.Caption) - 10) Then '10 away
Else 'Not Even Close
End if[/code]
Try that..
~-~(HDX)~-~
December 22, 2004, 7:07 AM
Reaper
Works like a charm, thanks :D
December 23, 2004, 4:08 PM

Search