Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i get rid of doubles from my database? Bill Excel Discussion (Misc queries) 2 April 27th 10 07:55 AM
Summarizing doubles Sippan Excel Worksheet Functions 1 June 17th 08 09:05 AM
Sorting doubles rbrunz Excel Discussion (Misc queries) 1 June 13th 08 04:20 PM
Cell height doubles after paste PBlake Excel Discussion (Misc queries) 1 October 29th 05 07:57 PM
How do I set up a Doubles Tennis roster for 12 players? AliJax New Users to Excel 3 September 17th 05 12:31 AM


All times are GMT +1. The time now is 10:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"