find a character in string

Hi I have a variable
server = "sqlmodl2\sql_modl2"

I want server2 =modl2

i.e I want to return all the characters after the _.


Can anyone help me.


Answer this question

find a character in string

  • Holm76

    Here are two ways to do it:

            Dim server As String = "sqlmodl2\sql_modl2"
            Dim server2 As String = Split(server, "_")(1)
            Debug.Print(server2)
            server2 = server.Substring(server.LastIndexOf("_") + 1)
            Debug.Print(server2)

    There are probably several more ways to do it as well.



  • rsws

    Mr. Carr

    As usual you have been very helpful.

  • find a character in string