greater then / less then

G

Guest

Why can I not compare 2 numbers?

what i have is this:

dim T as string = "101"
dim W as string = "99"

if T > W then
response.write("T is greater")
end if

if the numbers look like this is doesn't compare them. if they are both over
a 100 it works, and if they are both under 100 it works but if they are like
above it fails, how can i get this working?
I also tired the "classic asp" way and same results
 
S

Steve C. Orr [MVP, MCSD]

Do you want to compare them as strings or as numbers?
If you want to evaluate them as numbers (as I suspect you do) then try this
code instead to convert them to integers before comparing:

If CInt(T) > CInt(W) Then...

Of course it might be better to declare them as integers in the first place
instead of strings.
 
K

Kevin Spencer

You can compare 2 numbers. You're trying to compare 2 strings. A number is
not a string. A string is not a number.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top