Connecting Tech Pros Worldwide Forums | Help | Site Map

extracting the sub string from a string

Newbie
 
Join Date: Aug 2007
Posts: 7
#1: Aug 27 '07
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's Avatar
Familiar Sight
 
Join Date: Mar 2007
Location: VietNam
Posts: 175
#2: Aug 27 '07

re: extracting the sub string from a string


Quote:

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?

Expand|Select|Wrap|Line Numbers
  1. Dim subStr As String
  2. subStr = Mid(str,InStr(str,"QS"))   'now the substring = "QSquestion in a relevant forum"
  3. subStr = Left(subStr,InStr(subStr," ") - 1)   ' now the subStr  = "QSquestion"
  4. save subStr
  5.  
Newbie
 
Join Date: Aug 2007
Posts: 7
#3: Aug 27 '07

re: extracting the sub string from a string


Quote:

Originally Posted by pureenhanoi

Expand|Select|Wrap|Line Numbers
  1. Dim subStr As String
  2. subStr = Mid(str,InStr(str,"QS"))   'now the substring = "QSquestion in a relevant forum"
  3. subStr = Left(subStr,InStr(subStr," ") - 1)   ' now the subStr  = "QSquestion"
  4. save subStr
  5.  


its working fine Thanks a lot
Reply