VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

InStrLike

Atul Brad Buono  (3 Submissions)   String Manipulation   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

This is a combination of InStr and the Like operator. It returns the position of a mask within a string. The parameters are all user friendly variants just like the regular InStr function.
Example:
InStrLike("Test String 123abc45 Stuff","###*##")
returns 13, because 123abc45 matches the mask and it starts at character 13. Hope this is useful to somebody.

Inputs
Start=Position to start searching, optional String1=String to search String2=Mask to search for intCompareMethod=vbCompareMethod to use, optional

Assumes
This currently does not account for searching for the literal mask characters, which are normally enclosed in brackets in the mask. If that doesn't make sense to you then you are probably not doing it anyways so don't worry about it.

Returns
Returns a variant, which is null if String1 or String2 is null, otherwise returns the position of the mask (String2) within the string (String1). 0 if the mask is not present.

Rate InStrLike (8(8 Vote))
InStrLike.bas

InStrLike Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters