Below is my code, where I am getting confused...

This code is working fine : msgbox not displaying
-------------------------------------------------------
If "1" > "2" then
msgbox "wrong"
end if
-------------------------------------------------------
but
What is the problem in below code? if scenario is the same? : msgbox displaying
-------------------------------------------------------
If "99" > "100" then
msgbox "wrong"
end if
-------------------------------------------------------
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
"10"
string isn't the same as
10
number (integer type)

"1" > "2" - you are checking ONE STRING with ANOTHER.
Use
99 > 100
instead of
"99" > "100"
Answered 02/21/2011 by: itolutions
Orange Senior Belt

Please log in to comment
0
when comparing 2 string values like this in vbs, you compare the values in the ASCII table for the starting characters,

so "99">"100" is the same as "9">"1" in ASCII terms, so thats TRUE, that's why your messagebox shows up.

Rgds,

PJ
Answered 02/22/2011 by: pjgeutjens
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity