Finding text

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

I need to filter through lines of text and extract certain pieces. The
location of the text I need is in different areas. Can anyone tell me how
to do this? Here are some examples to better explain what I'm after.


c_login_hash=4698318f7583fb3647679a0ef6f4968a;+c_login=wealth;+c_user=wealth
;+c_user_type=u


c_login=abwang;+c_login_hash=a772b8f32fed82a4b6376b3387636370;+c_user_type=u
;+c_user=abwang


c_login=bp;+c_login_hash=72d08ec2e9e4c33e33404d0d42ce29dd;+c_user_type=p;+c_
user=ravinvi


c_login=clawrence;+c_login_hash=1163359b3c3ed86e774ba4bb85864b9c;+c_user_typ
e=p;+c_user=lawbros


What I need to extract is the name after "c_login=" and the name after
"c_user=" so I can use this data.

Please help!

Thank you in advance,
Tony
 
I would use the Split function to get the string into an
array:

Public Function FindLogin(strText As String) As String
Dim Values() As String
Dim intCounter As Integer
Values = Split(strText, ";")
For intCounter = LBound(Values) To UBound(Values)
If InStr(Values(intCounter), "c_login=") > 0 Then
'This one has the value
'Find position of the =, then add one, and get the
rest of the string
FindLogin = Mid(Values(intCounter), InStr(Values
(intCounter), "=") + 1)
Exit For
End If
Next intCounter
End Function



Chris Nebinger
 
Back
Top