[thelist] VBScript InStr type mismatch

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Wed Jul 13 11:47:52 CDT 2005


   Does it say anything more explicit than "type mismatch"?  Not that I'm expecting it...

   The first example looks like you're expecting it to evaluate to a boolean expression, which I don't believe is the case in VBScript.  I can see why this might throw an error.

   In the second bit of code, when you say "these return the same error", is the error marked at the response.write line, or at the If...Then statement?  I wonder if the implicit conversion is throwing it, i.e. you're trying to append a string to an integer.  I know VBScript is variants-only, but sometimes this stuff comes up.

HTH,

Peter

 From: "Canfield, Joel" JCanfield at PacAdvantage.org

Using InStr and getting a type mismatch from the first line of this bit:

If (InStr(strKaiserPlanIDs,strPlanNumberString,1)) Then
bitKaiserPlan = bitKaiserPlan + 1
End If

The variable values giving the error are

strKaiserPlanIDs = 011|012|510|515|520|
strPlanNumberString = B02

InStr isn't particularly mysterious; in this case, obviously it'll
return zero 'cause it's not found, but I don't understand the 'type
mismatch'

These return the same error:

response.write(InStr(strKaiserPlanIDs,strPlanNumberString,1) & "
")

If (InStr(strKaiserPlanIDs,strPlanNumberString,1) > 0) Then
bitKaiserPlan = bitKaiserPlan + 1
End If

thanks

joel


More information about the thelist mailing list