-
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
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks