Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

VB6 find string at a given index

  • 28-06-2006 03:28PM
    #1
    Registered Users, Registered Users 2 Posts: 4,333 ✭✭✭


    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, Registered Users 2 Posts: 4,333 ✭✭✭lukin


    Thanks Torak


  • Registered Users, Registered Users 2 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