INSTR function, but with multiple operands?

sts023

Registered User.
Local time
Today, 02:25
Joined
Dec 1, 2010
Messages
40
Hi guys....

Does anyone know of a function similar to INSTR, but which will take multiple delimiters?


I'd like to search for various possible substrings within a given string using something like

Code:
Dim intPtr          As Integer
Dim strSource    As String
  strSource = "This is a silly question to ask, but you never know!"
  intPtr = AdvancedInstr(strSource, "question", "never", "silly")
such that the pointer intPtr would have a value of 11 (counting from 1), because that is where the first of the located subtrings started.

Does anyone know of such a function?
I suspect I may have to write my own code to determine the earliest presence of any of a variable number of substrings, and return its offset.

Unless any of you guys know better.....
 
You will need a custom function and it isn't particularly complex.

However I would not structure the arguments like that because that system does not handle a variable number of arguments well. Of course you could include many arguments and make them optional but it won't loop well inside the function.

Use an array of strings as the argument.
 

Users who are viewing this thread

Back
Top Bottom