Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB6 find string at a given index

Options
  • 28-06-2006 3:28pm
    #1
    Registered Users Posts: 4,037 ✭✭✭


    Is there a method in VB6 that will find a substring of a string given it's position in the string?
    I know how to do it in VB.NET (below)


    Dim StrText1 as String = ""
    Dim StrText2 as String = ""
    StrText1 ="Hello"
    StrText2 = (strText1.Chars(1))

    The above code would return "ello" to the variable StrText2.


Comments

  • Closed Accounts Posts: 80 ✭✭Torak


    Right()


  • Registered Users Posts: 4,037 ✭✭✭lukin


    Thanks Torak


  • Registered Users Posts: 1,456 ✭✭✭FSL


    Right(string, length) just gives the number of characters from the right specified by length. Mid(string, start[, length]) returns then number of characters specified by length, from string, starting at start. If length is not specified or is greater than the number of characters from start to the end of then it returns all the charaters from start to the end.


  • Closed Accounts Posts: 2,268 ✭✭✭mountainyman


    To return the substring use
    Left$
    Right$

    dim strFilename as String
    Dim strLastSlash as String
    dim strDirectory as String

    strLastSlash = InStrRev(strFilename, "\")
    strDirectory = Left$(strFilename, strLastSlash)

    MM


Advertisement