Link to home
Start Free TrialLog in
Avatar of wellsuited
wellsuited

asked on

ASP If then using like

Please see my code below. I cannot get the LIKE clause to work with this if then statement. What am I doing wrong?
Thanks
If (rstimes.Fields.Item("Prodoption").Value)  LIKE "Triple%" Then
varused = 3
end if

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ALaRiva
ALaRiva
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Anthony Perkins
>>I cannot get the LIKE clause to work with this if then statement. What am I doing wrong?<<
That is because the Visual Basic Like operator is not supported in VBScript.  See here for a complete list of the differences between Visual Basic and VbScript:
http://msdn.microsoft.com/en-us/library/30593abb(VS.85).aspx

Just a minor correction to the previous workaround (no points please):

If Instr(1, rstimes.Fields.Item("Prodoption").Value,"Triple", vbTextCompare) = 1 Then
   varused = 3
End If

You should also be able to use RegEx for the same result.
Thanks acperkins, I always forget that detail.