strComp not doing what it should

S

steven scaife

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
 
B

Bob Barrows [MVP]

steven said:
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
 

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,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top