• Welcome to Valhalla Legends Archive.
 

Add bet to winnings

Started by Reaper~, December 23, 2004, 10:21 AM

Previous topic - Next topic

Reaper~


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

Take my advice, I'm not using it.

Hdx

frmAcount.lblWinning1.Caption
Is that an object? a valid one?
And please keep all your help requests in one thread >.<
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Reaper~

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"

?
Take my advice, I'm not using it.

NicoQwertyu

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?

Reaper~

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...
Take my advice, I'm not using it.

Grok

Actually, it looks like what was wrong with the original code was spelling of frmAccount.

Stealth

Use Option Explicit to avoid that happening again, and remember, the Tab key is your friend. :)
- Stealth
Author of StealthBot

R.a.B.B.i.T