Link to home
Start Free TrialLog in
Avatar of quan-chi
quan-chi

asked on

How can I Select a part of a text (automatic selection)

The thing is that using the Inet Control (http://checkip.dyndns.org/index.html) to get my IP it returns this: (with Text1.Text = Inet1.OpenURL)

<html><head><title>Current IP Check</title></head><body>Current IP Address: 200.43.19.76</body></html>

how can I put only the text, for exmple, between "Address:" and "</body>" ?
thx guys! ;)
Avatar of Shauli
Shauli

Dim myString As String, finalString As String
myString = "<html><head><title>Current IP Check</title></head><body>Current IP Address: 200.43.19.76</body></html>"

finalString = Mid(myString, (InStr(1, myString, "Address:") + 8), Len(myString) - (InStrRev(myString, "</body>", -1)))
MsgBox Trim(finalString)

You can also write a regular expression.
strtemp = "<html><head><title>Current IP Check</title></head><body>Current IP Address: 200.43.19.76</body></html>"

strte = Mid(strtemp, InStr(1, strtemp, "Address") + Len("Address") + 1, Len(strtemp) - InStr(1, strtemp, "</body>"))

stradd = strte & " This is test "

strfin = Mid(strtemp, 1, InStr(1, strtemp, "Address") + Len("Address") + 1) & stradd & Mid(strtemp, InStr(1, strtemp, "</body>"))
ASKER CERTIFIED SOLUTION
Avatar of learning_t0_pr0gram
learning_t0_pr0gram

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial