extracting the sub string from a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ammmmmu
    New Member
    • Aug 2007
    • 7

    #1

    extracting the sub string from a string

    Hi all,

    I need a code to extract the sub string from a string in VB6

    EX I have a string
    str = "Post your QSquestion in a relevant forum"
    and I want to store the word which starts from QS in the above string ie I want to store QSquestion in other string..

    How can I do this?
  • pureenhanoi
    New Member
    • Mar 2007
    • 175

    #2
    Originally posted by ammmmmu
    Hi all,

    I need a code to extract the sub string from a string in VB6

    EX I have a string
    str = "Post your QSquestion in a relevant forum"
    and I want to store the word which starts from QS in the above string ie I want to store QSquestion in other string..

    How can I do this?
    Code:
    Dim subStr As String
    subStr = Mid(str,InStr(str,"QS"))   'now the substring = "QSquestion in a relevant forum"
    subStr = Left(subStr,InStr(subStr," ") - 1)   ' now the subStr  = "QSquestion"
    save subStr

    Comment

    • ammmmmu
      New Member
      • Aug 2007
      • 7

      #3
      Originally posted by pureenhanoi
      Code:
      Dim subStr As String
      subStr = Mid(str,InStr(str,"QS"))   'now the substring = "QSquestion in a relevant forum"
      subStr = Left(subStr,InStr(subStr," ") - 1)   ' now the subStr  = "QSquestion"
      save subStr

      its working fine Thanks a lot

      Comment

      Working...