# Newbie: Calculations using Currency

• 03-22-2002, 10:34 AM
Magic
Newbie: Calculations using Currency

Is there a bug in the Currency setting in VB?

The following works fine if the wsCheck is >= to
the first wsExp.
Example: wsCheck = \$30.00
wsExp(1)= 10
wsExp(2)= 10
wsExp(3)= 30
The \$30.00 > 10.

But if the wsCheck is < the first wsExp,
Example: wsCheck = \$5.00
wsExp(1)= 10
wsExp(2)= 10
wsExp(3)= 30
it takes the \$5.00 as > 10.

I've tried making the variables "Currency,
but still does not work right.

My Code
-------
Dim wsCheck, wsPymt, wsExp, wsDiff As Double
wsCheck = Text1(10)
Do Until rs5.EOF = True
wsExp = rs5.Fields("Expected_Amt")

If wsCheck >= wsExp Then
wsPymt = wsExp
wsCheck = wsCheck - wsExp
Else
If wsCheck > 0 Then
wsPymt = wsCheck
wsDiff = wsCheck - wsExp
wsCheck = wsCheck - wsExp
Else
wsPymt = 0
wsDiff = wsExp * -1
End If
End If
rs5.Edit
rs5.Fields("Payment") = wsPymt
rs5.Fields("Difference") = wsDiff
rs5.Update
rs5.MoveNext
Loop
Data5.Refresh

Any help given will be appreciated,

Magic
• 03-22-2002, 07:23 PM
Arthur Wood
Re: Newbie: Calculations using Currency

Magic,
Since you claim to be a "newbie" I will be "gentle" on you.

1) It is considered to be EXTREMELY rude, to post EXACTLY the same question
in 2 discussion groups. Please read the Discussion Group Riles at http://www.devx.com/newspolicy.asp.

2) This is not really a Database question, and it was correctly posted in
Getting Started, where you in fact have an answer.

Arthur Wood

"Magic" <magic1521@hotmail.com> wrote:
>
>Is there a bug in the Currency setting in VB?
>
>The following works fine if the wsCheck is >= to
>the first wsExp.
>Example: wsCheck = \$30.00
> wsExp(1)= 10
> wsExp(2)= 10
> wsExp(3)= 30
>The \$30.00 > 10.
>
>But if the wsCheck is < the first wsExp,
>Example: wsCheck = \$5.00
> wsExp(1)= 10
> wsExp(2)= 10
> wsExp(3)= 30
>it takes the \$5.00 as > 10.
>
>I've tried making the variables "Currency,
>but still does not work right.
>
>My Code
>-------
> Dim wsCheck, wsPymt, wsExp, wsDiff As Double
> wsCheck = Text1(10)
> Do Until rs5.EOF = True
> wsExp = rs5.Fields("Expected_Amt")
>
> If wsCheck >= wsExp Then
> wsPymt = wsExp
> wsCheck = wsCheck - wsExp
> Else
> If wsCheck > 0 Then
> wsPymt = wsCheck
> wsDiff = wsCheck - wsExp
> wsCheck = wsCheck - wsExp
> Else
> wsPymt = 0
> wsDiff = wsExp * -1
> End If
> End If
> rs5.Edit
> rs5.Fields("Payment") = wsPymt
> rs5.Fields("Difference") = wsDiff
> rs5.Update
> rs5.MoveNext
> Loop
> Data5.Refresh
>
>
> Any help given will be appreciated,
>
> Magic