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
Solved

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

Posted on 2007-04-09
8
811 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
ID: 18880808
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
ID: 18880851
0
 
LVL 11

Assisted Solution

by:TreyH
TreyH earned 125 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

837 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