Newbie ASP question

They have: 133 posts

Joined: Sep 2000

Hi,

Once again I have a simple VBscript question...

How do I check if a variable/string contains a special value; in javascript its something like
if indexof(variablename, "forum") > 1 {}
etc...
But whats the parameters for this in ASP?

I have an ASP book, but it doesn't cover all these small gadgets... I will buy a new one sometime soon...

Hope you can help me.

Thank you
¨Casper
Cheers!

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

Your looking for the InStr function:

If InStr(1,variablename, "forum") > 1 Then
'whatever
Else
'whatever
End If

BTW You can write your ASP pages in Javascript if you're more comfortable with it.

PJ | Are we there yet?
pjboettcher.com

They have: 133 posts

Joined: Sep 2000

Thanks, works prefectly.

One question though, the first parameter (1). what is that for? Can you explain please?

Thanks
Casper

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

The 1 parameter tells InStr to start searching the string at the first character (beginning of string), if we changed it to 5 then it would start it's search on the 5th character.

PJ | Are we there yet?
pjboettcher.com

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.