View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default True Or False, no matter what... it still displays the false statement

Rocky,

How are the variables X and Y declared, and are their values
computed? It might be the case that the inherent rounding issues
with Double or Single variables causes their values to be
unequal. For example, X might be 3.00000000000001 and Y might be
3.000000000002.

What happens if you write your code like

If Abs(X-Y) < 0.0001 Then

You might want to post the code that assigns the values to X and
Y.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"rocky640 " wrote in
message ...
True Or False, no matter what... it still displays the false

statement

If X = Y then
msgbox("They are equal")
else
msgbox("They are not equal")
end if

Ok, both X and Y are set to 3. But, the message box "They are

not
equal" is still shown.

I know that both X and Y is set to 3 because when the macro is

running
I but my curser over the variable and it tells me it is equal

to 3.


---
Message posted from http://www.ExcelForum.com/