Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why does this comparison fail?

Status
Not open for further replies.

bookouri

IS-IT--Management
Feb 23, 2000
1,464
US
<%target = rsnamelist(&quot;ID&quot;) %>

<% do while rsnamelist(&quot;id&quot;)= target %>

do some stuff

<% RSNameList.MoveNext %>
<% target = rsnamelist(&quot;id&quot;) %>
<% loop %>

my loop fails at the <% do while ..... %> with an error:
Type mismatch
/asp/reports/test.asp, line 100

Its my understanding that all variables are the same type in vb scripting? What am I doing wrong?


thanks





 
Varables are not of the same type. You just dont have to define them. They will be converted to the type once you store data in them.

You may need to cast the varable before you compare it. I have the problme sometimes where I have a varable and it has a number, and I am comparing it to another numeric number, unless I cast it as an INT, it gives me the same error.

Example:

Dim myNum
myNum = Request.Form(&quot;userinput&quot;)

If (int(myNum) = 8) Then ...

End If

Hope that helps.

Mark A horse walks into the bar, and the bartender says &quot;Why the long face&quot;?
 
if i try to change any of the variable types I get errors because vb script only recognizes the VARIANT type.

 
Rather than trying to compare it against the fucntion. Try comparing 2 varables. Like so:

<%target = rsnamelist(&quot;ID&quot;) %>
<%newtarget = rsnamelist(&quot;ID&quot;) %>


<% do while newtarget= target %>

do some stuff

<% RSNameList.MoveNext %>
<% newtarget = rsnamelist(&quot;id&quot;) %>
<% loop %>
 
I tried using the variables rather than the function but I still get the same data mismatch error.

It cant be this difficult. Ive always had good luck using asp/vb for projects, and this is one of the simplest things Ive tried to do and I just cant seem to make it work.

thanks again for the replies
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top