Trouble with comparisons

1. confused! Guest

## Trouble with comparisons

Hi - I&#039;m lost. I am comparing two variables, and when they&#039;re equal, I am putting one in an array. Here&#039;s my code: (Please look at the comments for further explaination)<BR><BR>do while not RS.EOF<BR> for i=0 to 61<BR> temp = arrClasses(i)<BR> if (temp&#060;&#062;"") Then<BR> firstslash = Instr(1, temp, "@")<BR> firstslash = firstslash - 1<BR> temp2 = Left(temp, firstslash)<BR> firstslash = firstslash + 2<BR>&#039;GETTING A NUMBER VALUE<BR> temp3 = Right(temp, firstslash) <BR>&#039;HERE&#039;S WHERE I PRINT OUT THE VARIABLES TO SEE IF THEY MATCH. I USED THE PIPE SYMBOLS TO MAKE SURE THERE WERE NO SPACES BEFORE OR AFTER THE VARIABLES, AND THERE ISN&#039;T<BR> response.write "&#124" & temp2 & "&#124 &#124"<BR> response.write RS("CourseID") & "&#124"<BR>&#039;A NUMBER VALUE<BR> temp4 = RS("CourseID")<BR>&#039;HERE&#039;S MY COMPARISON. FOR SOME REASON.. IT IS NOT WORKING. EVEN WHEN THE 2 VARIABLES MATCH<BR> if (temp3 = temp4) Then<BR> response.write "TEST" & "<BR>"<BR> arrClasses(i) = RS("CourseName") & " - " & temp3<BR> end if<BR> end if<BR> next<BR> rs.MoveNext<BR>loop<BR><BR><BR>any ideas?

2. Dom
Senior Member
Join Date
Dec 1969
Posts
256

## Have you tried a type conversion?

If they are integers you might want to make temp3 = CInt(temp3)<BR>Not sure if this is necessary but try it!

3. confused! Guest

## RE: Have you tried a type conversion?

thanks - i tried it but i got an error: <BR><BR>Microsoft VBScript runtime error &#039;800a000d&#039; <BR><BR>Type mismatch: &#039;CInt&#039; <BR><BR>

4. Dom
Senior Member
Join Date
Dec 1969
Posts
256

## RE: Have you tried a type conversion?

Then it&#039;s not a number so it isn&#039;t going to match the number you get out of the database is it? If you have a string which just contains a number then CInt(yourstring) should work. Do you always get a number as the result of your string manipulation or not?

5. confused! Guest

## RE: Have you tried a type conversion?

yes, the variable out of the string manipulation is always a number. when i used the CInt(string) on the variable out of the string manipulation (which will always be a number), it gives me that error. the CInt(string) worked when i used it for the variable coming out of the database, but the comparison did not work. i even added a letter to the variable out of the database, then extracted the number out (w/o the just added letter) to try to make it into a string and not a number. that did not work... i just don&#039;t get it!

6. Dom
Senior Member
Join Date
Dec 1969
Posts
256

## Also, which has the number?

Is it temp3 or temp2, because you&#039;re writing temp2 out but you&#039;re checking temp3. What is temp (the original data from the array) likely to look like?

7. co Guest

## RE: Also, which has the number?

that was it! i was comparing the wrong variables! thanks!

#### Posting Permissions

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