Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing Doubles
Hi everyone,
I have a section of code where I'm trying to see if a variable (UserCompSum), declared as a double, is equal to 100, like this: Dim UserCompSum As Double If UserCompSum = 100 Then bUserCompSum = True End If but even when UserCompSum is equal to 100 the code doesn't seem to think so and I get stuck with bUserCompSum = False. I have a workaround by doing this: If CInt(UserCompSum) = 100 Then bUserCompSum = True End If but this seem a little inelegant to me. Does anyone know how to compare Double values? TIA big t |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Comparing Doubles
big t,
Depending on the nature of the comparison, something like: If Abs(UserCompSum-TestValue)<Threshold Then You would have to decide on the Threshold value that you can tolerate. NickHK "big t" wrote in message ... Hi everyone, I have a section of code where I'm trying to see if a variable (UserCompSum), declared as a double, is equal to 100, like this: Dim UserCompSum As Double If UserCompSum = 100 Then bUserCompSum = True End If but even when UserCompSum is equal to 100 the code doesn't seem to think so and I get stuck with bUserCompSum = False. I have a workaround by doing this: If CInt(UserCompSum) = 100 Then bUserCompSum = True End If but this seem a little inelegant to me. Does anyone know how to compare Double values? TIA big t |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i get rid of doubles from my database? | Excel Discussion (Misc queries) | |||
Summarizing doubles | Excel Worksheet Functions | |||
Sorting doubles | Excel Discussion (Misc queries) | |||
Cell height doubles after paste | Excel Discussion (Misc queries) | |||
How do I set up a Doubles Tennis roster for 12 players? | New Users to Excel |