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!

String Parsing

Status
Not open for further replies.

cryoburned

Programmer
May 23, 2006
14
US
yea so.. if I had string "Abc im cool cba" how could i get the stuff between abc and cba? I don't have direct acess to this string so I cn't edit it myself
 
I figured out how to parse it I think.. I get an error with this code:
[vb]
Dim HTMLMYSPACE As String
Private Sub KewlButtons1_Click()
Do Until Inet1.StillExecuting = False
HTMLMYSPACE = Inet1.OpenURL("Loop
Dim What As String
Dim ToS As String
Dim FromS As String
Dim TMP As String
FromS = "<form action="""
ToS = " "" method=""post"" name=""theForm"" id=""theForm"">"
TMP = Mid(HTMLMYSPACE, InStr(HTMLMYSPACE, FromS) + Len(FromS) + 1, Len(What))
TMP = Left(TMP, InStr(TMP, ToS) - 1)
HTMLMYSPACE = TMP
End Sub
[/vb]
Error: Invalid Procedure call or argument on this line:
TMP = Left(TMP, InStr(TMP, ToS) - 1)
 
I don't know about your own responce, but to answer your OP:
Code:
Dim str As String
Dim ary() As String
Dim i As Integer

str = "Abc im cool cba"

ary = Split(str, " ")

For i = LBound(ary) + 1 To UBound(ary) - 1
    Debug.Print ary(i)
Next i

Have fun.

---- Andy
 
And, as a fun alternative:
Code:
[blue]Private Function stripstring(strSource As String) As String
    Dim result As Object
    With CreateObject("vbscript.regexp")
        .Pattern = "(?:abc)(.*)(?:cba)"
        Set result = .Execute("abc im cool cba")
        If result.Count Then stripstring = result(0).SubMatches(0)
    End With
End Function[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top