If frmAccount.lblWinning1.Caption = "$500" Then
Val (lblWinning1.Caption) + Val(txtBet.Text)
End If
If frmAcount.lblWinning1.Caption = "$300" Then
Val (lblWinning1.Caption) + Val(txtBet.Text)
End If
I tried that but I get a runtime error saying Object Required and it highlights
If frmAcount.lblWinning1.Caption = "$300" Then
frmAcount.lblWinning1.Caption
Is that an object? a valid one?
And please keep all your help requests in one thread >.<
~-~(HDX)~-~
Quote from: HdxBmx27 on December 23, 2004, 10:24 AM
frmAcount.lblWinning1.Caption
Is that an object? a valid one?
And please keep all your help requests in one thread >.<
~-~(HDX)~-~
Guess not, but what would be the way to add it under one of the winning procedures?
Something like...
ElseIf (Val(txtNumber.Text) <= Val(lblNumber.Caption) + 5) And (Val(txtNumber.Text) >= Val(lblNumber.Caption) - 5) Then
MsgBox ("5 Away! $300 has been sent to your account!")
frmAccount.lblWinning1.Caption = "$300"
Val(frmAccount.lblWinning1.Caption) = Val(txtBet.Text) + "$300"
?
Quote from: Reaper~ on December 23, 2004, 10:41 AM
frmAccount.lblWinning1.Caption = "$300"
Val(frmAccount.lblWinning1.Caption) = Val(txtBet.Text) + "$300"
There's a couple wierd things going on with that code.
Val(frmAccount.lblWinning1.Caption)
Val(txtBet.Text)
1.) Val() will always return 0 because it's including the dollar sign "$".
1a.) Fix it by leaving the first character of the caption out when calling Val.
1b.) Don't know how to do that? Google string manipulation in VB6.
Val(txtBet.Text) + "$300"
2.) Why are you trying to do numerical addition using a string?
Thanks for the tip on the dollarsign and I got it what I wanted to work by adding:
Public Function GetBet()
GetBet = Val(txtBet.Text)
End Function
Then I put 'GetBet' under..
frmAccount.lblWinning1.Caption = "$300" + GetBet
So, now it works :D
All I have to do is add a seperate dollarsign next to where the amount would go in frmAccount...
Actually, it looks like what was wrong with the original code was spelling of frmAccount.
Use Option Explicit to avoid that happening again, and remember, the Tab key is your friend. :)
So are variables.