Professional Web Applications Themes

ASP comparison question... - ASP

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

  1. #1

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




    K Guest

  2. #2

    Default 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
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vbsvariables.asp[/url]

    Ray at work


    "K" <n_komvideotron.ca> wrote in message
    news:MbtWa.14679$Sn.185155wagner.videotron.net...
    > 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 Guest

  3. #3

    Default Re: ASP comparison question...

    K wrote:
    > 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.
    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


    Bob Barrows Guest

  4. #4

    Default Re: ASP comparison question...

    I am actually doi ng this:
    i = request.form("var1")
    j = request.form("var2")

    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:uSB6fsCWDHA.2476tk2msftngp13.phx.gbl...
    > 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
    >
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht[/url]
    ml/vbsvariables.asp
    >
    > Ray at work
    >
    >
    > "K" <n_komvideotron.ca> wrote in message
    > news:MbtWa.14679$Sn.185155wagner.videotron.net...
    > > 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.
    > >
    > >
    > >
    > >
    >
    >

    K Guest

Similar Threads

  1. Comparison among different PDF libraries
    By deepak_goyal@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 6
    Last Post: August 19th, 02:34 PM
  2. Resultset Comparison
    By alagukannan in forum Coldfusion Database Access
    Replies: 1
    Last Post: December 8th, 07:59 PM
  3. comparison between two regexes?
    By David Garamond in forum PERL Beginners
    Replies: 2
    Last Post: October 24th, 02:57 PM
  4. Mac - PC Comparison
    By Ed A. Ortiz in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 6
    Last Post: July 16th, 07:49 PM
  5. raw vs. ufs comparison
    By Jan Andres in forum Sun Solaris
    Replies: 5
    Last Post: July 16th, 10:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139