strComp not doing what it should

Discussion in 'ASP General' started by steven scaife, Jan 27, 2005.

  1. Ok i need to compare 2 values from my array but strComp no matter what
    returns 1 even though my comparison values are the same

    if i do this

    str1 = "wed"
    str2 = "wed"
    strComp(str1, str2) 'returns 0

    but if i do

    str1 = code(0)
    str2 = code(1)
    both are "wed" but it returns 1

    however if i do

    strComp(code(0), code(0)) 'returns 0

    I am unsure why it returns 1 even when they are the same, i have even tried
    cstr(code(0)) but it still returns 1

    my code i am going to use in my page is but its probably irrelevant as its
    suffering from same problems as outlined above

    tia for the help

    For i = 1 to loopcount
    If strComp(code(0), code(i), 0) = 0 Then
    Response.Write "<tr><td>You must enter the unique code for each item to
    continue</td></tr>"
    response.write "<tr><td align='center'><a
    href='javascript:history.back();'>Please go back and re-enter</td></tr>"
    Response.end
    Else
    Response.Write "<tr><td>The Codes are unique</td></tr>"
    response.write "<tr><td align='center'><a
    href='javascript:history.back();'>Please go back and re-enter</td></tr>"
    Response.end
    End If
    Next
     
    steven scaife, Jan 27, 2005
    #1
    1. Advertising

  2. steven scaife wrote:
    > Ok i need to compare 2 values from my array but strComp no matter what
    > returns 1 even though my comparison values are the same
    >
    > if i do this
    >
    > str1 = "wed"
    > str2 = "wed"
    > strComp(str1, str2) 'returns 0
    >
    > but if i do
    >
    > str1 = code(0)
    > str2 = code(1)
    > both are "wed" but it returns 1
    >
    > however if i do
    >
    > strComp(code(0), code(0)) 'returns 0
    >
    > I am unsure why it returns 1 even when they are the same, i have even
    > tried cstr(code(0)) but it still returns 1
    >
    > my code i am going to use in my page is but its probably irrelevant
    > as its suffering from same problems as outlined above
    >
    > tia for the help
    >


    I think your array does not contain what you think it contains. This code
    returns 0 when I run it:

    <%
    dim code(1)
    code(0) = "wed"
    code(1) = "wed"
    Response.Write StrComp(code(0),code(1))
    %>

    Response-write your values to verify the array contains what you expect it
    to contain.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jan 27, 2005
    #2
    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. Luis Ferrao
    Replies:
    1
    Views:
    359
    Peter Blum
    Jan 3, 2005
  2. Malcolm

    new strcomp() function.

    Malcolm, Dec 15, 2003, in forum: C Programming
    Replies:
    1
    Views:
    361
    Arthur J. O'Dwyer
    Dec 16, 2003
  3. TomK
    Replies:
    1
    Views:
    1,967
    Manish
    Feb 6, 2008
  4. TomK
    Replies:
    2
    Views:
    251
  5. Andrew Poulos

    Equivalent of Strcomp

    Andrew Poulos, Jan 5, 2007, in forum: Javascript
    Replies:
    32
    Views:
    472
    Richard Cornford
    Jan 8, 2007
Loading...

Share This Page