Format$(xoxo, "currency") question

shad0wslay3r
01-03-2008, 12:20 PM
I am trying to get a running total of some items entered, and it works just fine when i am not using the Format$, but when I try to convert it to a running total the output is always zero.

Private Sub Command1_Click()

If Check1.Value = 1 Then discount = ((Val(Text1.Text) * (Val(Text2.Text) / 100 + 1)) * 0.1) 'calculating the discount with tax included.

If Check1.Value = 0 Then discount = 0
'stating no discount if box is unchecked

Label5.Caption = Format$(Val(Text1.Text) * (Val(Text2.Text) / 100 + 1) - discount, "currency")
'if i remove the format$ here, and in the next line I will get a running total in label7.caption. however with format$ involved it always returns $00.00

Label7.Caption = Format$(Val(Label7.Caption) + Val(Label5.Caption), "currency")

End Sub

user name
01-03-2008, 12:40 PM
When using Val(), it returns the numeric value out of a string until it hits a non numeric char.

Because you are using Format you are putting the regional currency sign in front of it, so Val("$12.00") returns zero.

Welcome to the forum.

shad0wslay3r
01-03-2008, 01:16 PM
Ah.. DUH! lol

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum