Link to home
Start Free TrialLog in
Avatar of CMCONE
CMCONEFlag for United States of America

asked on

InStr Function in VB.NET

What happened to the InStr Function in VB.NET?  There is no starting position for the function.  My question is how would I find the 2nd, 3rd etc. ocurrence in a string.  Thanks for the help.

In VB6 I would simply do something like:

Dim tag_open As Integer
Dim tag_close As Integer
Dim str As String

str = "[This is a Test],[This is a test 2]"
tag_close = 1

Do
    tag_open = InStr(tag_close, str, "[")
    If tag_open = 0 Then Exit Do
    tag_open = tag_open + 1
    tag_close = InStr(tag_open, str, "]")
   
    Debug.Print Mid(str, tag_open, tag_close - tag_open)
    'tag_close = tag_open + 1
Loop
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But it isn't offered by 'Intellisense'. Only the older (VB3?)  - without the start position pops up.