Welcome to my ASP Code Website

InStr ASP String Function



InStr is a commonly used ASP function that allows you to determine where a character or characters falls within a string. This is much like the command loc or mid in other languages. It takes in 2 parameters:

* The string to operate on
* The character or characters to locate

The original string variable is not altered.

Let's say you have a string called UserName which is equal to "Lisa Shea". Now let's say you just want to know where the space falls in the username, so you can cut the string apart into the first name and last name at that point. You would use:

SpaceLoc = InStr(UserName, " ")

The result is that SpaceLoc would be equal to 5. You could then use that knowledge along with the total length of the string (found with the Len function) to use Left function and the Right function to chop up your string.



Still stuck? Please be sure to Contact Lisa Shea - that's me - and I'm happy to lend a hand. I've been programming in ASP classic for many, many years and can help you get through your coding challenge quickly and easily!

To have an easy to use, easy to read reference on hand as you code, also check out my Intro to ASP Book which comes in both ebook and paperback format.

Thanks for stopping in to my page - and good luck!

ASP String Functions