Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to manipulate a string ?

Status
Not open for further replies.

desprits

Programmer
Feb 14, 2004
40
CA
What should I do if I have this string and I just want to take this part of string.
Exemple : tijean 024:zFwA 204.92.0.41 Sat Feb 7 (00:01)
I just want to have "204.92.0.41" ?

Merci!
 
You need to use MID(<the string>, <thestart>,<howmanyletters>)

This will work if the string always has (for example) 18 letters before the items you want.
If not, you need to be more devious.

You would have to search for the first occurence of the '.'

with Instr(<thestring>,&quot;.&quot;)
That will tell you what position the '.' takes.
Subtract 3 from that, and then use MID()

e.g:
Mid(<thestring>,instr(<thestring>,'.')-3,12)

 
Private Function GetIPAddress(strSource As String) As String
With CreateObject(&quot;VBScript.RegExp&quot;)
.Pattern = &quot;(\d{1,3}\.){3}\d{1,3}&quot;
GetIPAddress = .Execute(strSource).Item(0)
End With
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top