greater then / less then

Discussion in 'ASP .Net' started by =?Utf-8?B?TWlrZQ==?=, Nov 4, 2004.

  1. 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
    =?Utf-8?B?TWlrZQ==?=, Nov 4, 2004
    #1
    1. Advertising

  2. 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.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "Mike" <> wrote in message
    news:...
    > 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
    Steve C. Orr [MVP, MCSD], Nov 4, 2004
    #2
    1. Advertising

  3. 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

    "Mike" <> wrote in message
    news:...
    > 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
    Kevin Spencer, Nov 4, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. falcon
    Replies:
    10
    Views:
    18,564
    Roedy Green
    Feb 24, 2006
  2. Replies:
    6
    Views:
    387
  3. jiajia wu
    Replies:
    0
    Views:
    346
    jiajia wu
    Oct 1, 2009
  4. Dwight Army of Champions
    Replies:
    4
    Views:
    2,705
    John H.
    Mar 17, 2010
  5. Roland Wolters
    Replies:
    2
    Views:
    115
    Bhaskardeep Khaund
    Dec 4, 2003
Loading...

Share This Page