![]() |
True Or False, no matter what... it still displays the false statement
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 no equal" is still shown. I know that both X and Y is set to 3 because when the macro is runnin I but my curser over the variable and it tells me it is equal to 3 -- Message posted from http://www.ExcelForum.com |
True Or False, no matter what... it still displays the false statement
This works for me:
'''''''''''''''''''''''' Dim X As Double, Y As Double X = 3 Y = 3 If X = Y Then MsgBox ("They are equal") Else MsgBox ("They are not equal") End If '''''''''''''''''''''''''''''''''''''' -- steveb (Remove 'NOSPAM' from email address if replying direct) "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/ |
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/ |
All times are GMT +1. The time now is 03:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com