Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Subtraction using double

Posted on 2004-04-29
4
Medium Priority
?
206 Views
Last Modified: 2010-05-02
Hi,

Im am running the following code:
frmAddToFile.txtBalance = Val(frmAddToFile.adoFileInformation.Recordset.Fields("saleamount")) - Val(frmAddToFile.txtTotalPaidToDate) - Val(txtAmountPaying.Text)

where frmAddToFile.adoFileInformation.Recordset.Fields("saleamount") = 10707.49
and frmAddToFile.txtTotalPaidToDate = 8022.89
and txtAmountPaying.Text = 2684.60

this should compute to 0 but instead it = -4.54747350.......

I understand this has to do with the way it is stored in binary, but I need a way of making this work.

Thanks!
0
Comment
Question by:FTIISD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 19

Assisted Solution

by:Shauli
Shauli earned 400 total points
ID: 10952137
frmAddToFile.txtBalance = (Val(frmAddToFile.adoFileInformation.Recordset.Fields("saleamount")) - (Val(frmAddToFile.txtTotalPaidToDate) + Val(txtAmountPaying.Text))

S
0
 
LVL 6

Assisted Solution

by:prasitlee
prasitlee earned 400 total points
ID: 10952161
HI FTIISD,
    Did you try to use the function cdbl() insteadof val() or not ? I think it might be better ...
                                                                   Meng
0
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 1200 total points
ID: 10952178
Try:

frmAddToFile.txtBalance = Val(Val(frmAddToFile.adoFileInformation.Recordset.Fields("saleamount")) - Val(frmAddToFile.txtTotalPaidToDate)) - Val(txtAmountPaying.Text)

or is will be better if you use CCur function instead:

frmAddToFile.txtBalance = CCur(frmAddToFile.adoFileInformation.Recordset.Fields("saleamount")) - CCur(frmAddToFile.txtTotalPaidToDate) - CCur(txtAmountPaying.Text)
0
 

Author Comment

by:FTIISD
ID: 10952274
Was able to get it working with CCur()

Thanks for the help!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question