Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2007-04-09
8
Medium Priority
?
822 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
[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
  • 3
  • 2
8 Comments
 
LVL 15

Expert Comment

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

Accepted Solution

by:
JackOfPH earned 500 total points
ID: 18880851
0
 
LVL 11

Assisted Solution

by:TreyH
TreyH earned 500 total points
ID: 18881976
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
ID: 19131607
Your call Dan, anything fine by me...
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 19155165
Yeah, its your call...
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Suggested Courses

610 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