DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Magic Guest

    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

  2. #2
    Arthur Wood Guest

    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



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links