Author | Message | Time |
---|---|---|
Reaper | [code] 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 [/code] I tried that but I get a runtime error saying Object Required and it highlights [code] If frmAcount.lblWinning1.Caption = "$300" Then [/code] | December 23, 2004, 4:21 PM |
HdxBmx27 | [code]frmAcount.lblWinning1.Caption[/code] Is that an object? a valid one? And please keep all your help requests in one thread >.< ~-~(HDX)~-~ | December 23, 2004, 4:24 PM |
Reaper | [quote author=HdxBmx27 link=topic=9995.msg93315#msg93315 date=1103819051] [code]frmAcount.lblWinning1.Caption[/code] Is that an object? a valid one? And please keep all your help requests in one thread >.< ~-~(HDX)~-~ [/quote] Guess not, but what would be the way to add it under one of the winning procedures? Something like... [code] 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" [/code] ? | December 23, 2004, 4:41 PM |
NicoQwertyu | [quote author=Reaper~ link=topic=9995.msg93316#msg93316 date=1103820063] [code] frmAccount.lblWinning1.Caption = "$300" Val(frmAccount.lblWinning1.Caption) = Val(txtBet.Text) + "$300" [/code] [/quote] There's a couple wierd things going on with that code. [code] Val(frmAccount.lblWinning1.Caption) Val(txtBet.Text) [/code] 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. [code] Val(txtBet.Text) + "$300" [/code] 2.) Why are you trying to do numerical addition using a string? | December 23, 2004, 7:11 PM |
Reaper | Thanks for the tip on the dollarsign and I got it what I wanted to work by adding: [code] Public Function GetBet() GetBet = Val(txtBet.Text) End Function [/code] Then I put 'GetBet' under.. [code] frmAccount.lblWinning1.Caption = "$300" + GetBet [/code] So, now it works :D All I have to do is add a seperate dollarsign next to where the amount would go in frmAccount... | December 23, 2004, 9:02 PM |
Grok | Actually, it looks like what was wrong with the original code was spelling of frmAccount. | December 24, 2004, 9:40 AM |
Stealth | Use Option Explicit to avoid that happening again, and remember, the Tab key is your friend. :) | December 24, 2004, 6:18 PM |
R.a.B.B.i.T | So are variables. | December 24, 2004, 9:41 PM |