Solved

Problem to compare double with lenght over 15 digits in visual basic 6

Posted on 2007-04-09
8
804 Views
Last Modified: 2008-01-09
I face a problem to compare double with lenght over 15 digits in visual basic 6.
For example:
Dim a  as double, b as double
a = "100000000000000000"
b = "100000000000000001"
when compare a = b .. this will return True. Why true ?
when a = a + 1.. it shows 1E + 17.. how to make it show 100000000000000001 ? Pls help. Thanks.
0
Comment
Question by:alankwan
  • 3
  • 2
8 Comments
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
The only possible I know is to declare the variable variant.
Dim a, b
0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 125 total points
Comment Utility
0
 
LVL 11

Assisted Solution

by:TreyH
TreyH earned 125 total points
Comment Utility
Working with that many significant digits (In VB6) would require a 3rd party library. I've used one called xlPrecision. There's a free edition you can download to try it out. It's mainly designed for Excel but I've used it in VB with no problem.

http://precisioncalc.com/xlprecision.html
http://precisioncalc.com/UseInVBA.html

Example Code for comparing your two numbers.

Dim oXLP As xlPrecision.cls_xlPrecision
Set oXLP = New xlPrecision.cls_xlPrecision
If oXLP.xlpISEQUAL("100000000000000000", "100000000000000001") Then
    MsgBox "Numbers are equal"
Else
    MsgBox "Numbers are not equal"
End If
Set oXLP = Nothing
0
 
LVL 11

Expert Comment

by:TreyH
Comment Utility
Your call Dan, anything fine by me...
0
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
Yeah, its your call...
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now