Link to home
Start Free TrialLog in
Avatar of LeighWardle
LeighWardleFlag for Australia

asked on

vb.net - How to determine string that follows a given substring

Hi Experts,

Is there a simple way to return "userfoldername", the string that follows "/USERFOLDER=" in this example?

"/USERFOLDER=userfoldername"

Regards,
Leigh
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try use IndexOf function

http://www.dotnetperls.com/indexof-vbnet
with substring function.
Avatar of LeighWardle

ASKER

Thanks, Ryan.

Would you mind combining the 2 parts, IndexOf function and substring function?

Regards,
Leigh
something like this...
Sub Main()
        Dim test As String = "/USERFOLDER=userfoldername"
        Dim idx As Integer = test.IndexOf("=")
        Dim result As String = ""
        If idx > -1 Then
            result = test.Substring(idx+1, test.Length-idx-1)
        End If
        Console.WriteLine("Result = " + result)
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore 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
Is that ALL that is in the string?...or will that be mixed in with other values?
Thanks, Ryan, your simple example works a treat!
Regards,
Leigh