ASP comparison question...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • K

    ASP comparison question...

    hi guys,


    I am doing this here:

    dim i
    dim j

    i = 10
    j = 10

    If i = j then

    But it is giving me a false result...

    Any ways to do this comparison so it gives me the proprer result?

    Thanx.




  • Ray at

    #2
    Re: ASP comparison question...

    Are you sure this is all there is to it? Just that code alone should return
    true, but if you're assinging i and j by some other means, it's likely that
    one of them is a string and one is an integer, or something along those
    lines. Doing this will take care of it though:

    If CInt(i) = CInt(j) Then...


    Depending on what kind of values you're using, you may want CLng to avoid an
    overflow, i.e.
    i = 32938493
    j = 32938493

    If CInt(i) = CInt(j) Then
    '''Will cause an overflow


    Ray at work


    "K" <n_kom@videotro n.ca> wrote in message
    news:MbtWa.1467 9$Sn.185155@wag ner.videotron.n et...[color=blue]
    > hi guys,
    >
    >
    > I am doing this here:
    >
    > dim i
    > dim j
    >
    > i = 10
    > j = 10
    >
    > If i = j then
    >
    > But it is giving me a false result...
    >
    > Any ways to do this comparison so it gives me the proprer result?
    >
    > Thanx.
    >
    >
    >
    >[/color]


    Comment

    • Bob Barrows

      #3
      Re: ASP comparison question...

      K wrote:[color=blue]
      > hi guys,
      >
      >
      > I am doing this here:
      >
      > dim i
      > dim j
      >
      > i = 10
      > j = 10
      >
      > If i = j then
      >
      > But it is giving me a false result...
      >
      > Any ways to do this comparison so it gives me the proprer result?
      >
      > Thanx.[/color]
      Well, I can't reproduce your error.

      This:
      dim i
      dim j

      i = 10
      j = 10

      If i = j then
      Response.Write "Equal"
      else
      Response.Write "Not Equal"
      end if
      Response.End

      gives this result:
      Equal

      Suggestion: force both variable to the same data subtype:
      i=cint(10)
      j=cint(10)

      HTH,
      Bob Barrows


      Comment

      • K

        #4
        Re: ASP comparison question...

        I am actually doi ng this:
        i = request.form("v ar1")
        j = request.form("v ar2")

        And later, I do;

        If i = j then
        response.write
        Else
        response.write
        End If

        when I try =" or ,+, one return true, the other one false.
        So I guess it is comparing the value in itself and not what it holds.

        If I do Cint(j) I will get the actual value of the letter won't I?

        Thx.



        "Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
        news:uSB6fsCWDH A.2476@tk2msftn gp13.phx.gbl...[color=blue]
        > Are you sure this is all there is to it? Just that code alone should[/color]
        return[color=blue]
        > true, but if you're assinging i and j by some other means, it's likely[/color]
        that[color=blue]
        > one of them is a string and one is an integer, or something along those
        > lines. Doing this will take care of it though:
        >
        > If CInt(i) = CInt(j) Then...
        >
        >
        > Depending on what kind of values you're using, you may want CLng to avoid[/color]
        an[color=blue]
        > overflow, i.e.
        > i = 32938493
        > j = 32938493
        >
        > If CInt(i) = CInt(j) Then
        > '''Will cause an overflow
        >[/color]

        ml/vbsvariables.as p[color=blue]
        >
        > Ray at work
        >
        >
        > "K" <n_kom@videotro n.ca> wrote in message
        > news:MbtWa.1467 9$Sn.185155@wag ner.videotron.n et...[color=green]
        > > hi guys,
        > >
        > >
        > > I am doing this here:
        > >
        > > dim i
        > > dim j
        > >
        > > i = 10
        > > j = 10
        > >
        > > If i = j then
        > >
        > > But it is giving me a false result...
        > >
        > > Any ways to do this comparison so it gives me the proprer result?
        > >
        > > Thanx.
        > >
        > >
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...