To read the article online, visit http://www.4GuysFromRolla.com/webtech/code/InStr.shtml

InStr(str, SearchForStr) : Returns the location a character (charSearchFor)
                           was found in the string str
========================================================================

// InStr function written by: Steve Bamelis - steve.bamelis@pandora.be

function InStr(strSearch, charSearchFor)
/*
InStr(strSearch, charSearchFor) : Returns the first location a substring (SearchForStr)
                           was found in the string str.  (If the character is not
                           found, -1 is returned.)
                           
Requires use of:
	Mid function
	Len function
*/
{
	for (i=0; i < Len(strSearch); i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}


Article Information
Article Title: 4GuysFromRolla.com
Article Author: Scott Mitchell
Article URL: http://www.4GuysFromRolla.com/webtech/code/InStr.shtml


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers