Private Sub Command1_Click()
Dim Start1 As Long, Rounds As Integer, Bids1 As Integer
Dim sort As String, Inter As Long, A5 As Boolean
Command1.Enabled = False
Text1.Text = Replace(Text1.Text, "+", " ")
ListView1.Sorted = False
ListView1.ListItems.Clear
On Error Resume Next
Inter = 0
A5 = False
sort = ""
Rounds = 0
Loop2:
Source = Get1.OpenURL("http://search.ebay.com/search/search.dll?GetResult&
query=" & Text1.Text & "&from=R8&ht=1&combine=y&itf=1&st=2&SortProperty=MetaEndSort" & sort)
Start1 = 1
Start1 = InStr(Start1, Source, ">Item Title</font>", vbTextCompare)
Loop1:
If Start1 > 0 And InStr(Start1 + 1, Source, "</td><td valign=top width=52%><font size=3><a href=", vbTextCompare) > 0 Then
start2 = InStr(Start1, Source, "</td><td valign=top width=52%><font size=3><a href=", vbTextCompare)
start2 = start2 + 52
end2 = InStr(start2, Source, ">", vbTextCompare)
end2 = end2 - 1
Len1 = end2 - start2
link = Mid(Source, start2, Len1)
start3 = end2 + 2
end3 = InStr(start3, Source, "<", vbTextCompare)
end3 = end3
len3 = end3 - start3
Title = Mid(Source, start3, len3)
start5 = InStr(end3, Source, "$", vbTextCompare)
end5 = InStr(start5, Source, "<", vbTextCompare)
len5 = end5 - start5
Price = Mid(Source, start5, len5)
Start4 = InStr(end3, Source, "width=10%><font size=3>", vbTextCompare)
Start4 = Start4 + 23
end4 = InStr(Start4, Source, "<", vbTextCompare)
len4 = end4 - Start4
Bids = Mid(Source, Start4, len4)
If Bids = "-" Or Bids = "" Then Bids = 0
Bids1 = Bids
ListView1.ListItems.Add , , Title
ListView1.ListItems(ListView1.ListItems.Count).ListSubItems.Add , , Price
ListView1.ListItems(ListView1.ListItems.Count).ListSubItems.Add , , Bids1
ListView1.ListItems(ListView1.ListItems.Count).ListSubItems.Add , , link
Start1 = end4 + 1
DoEvents
If StopSearch = True Then
StopSearch = False
GoTo End1:
End If
Items = Items + 1
Label1.Caption = Items
If Not Start1 = 0 Then
If InStr(Start1, Source, "</td><td valign=top width=52%><font size=3><a href=", vbTextCompare) > 0 Then GoTo Loop1
End If
If A5 = False Then
Tstart5 = InStr(1, Source, "[/B] items found for ", vbTextCompare)
Tstart5 = Tstart5 - 10
start5 = InStr(Tstart5, Source, "[B]", vbTextCompare)
start5 = start5 + 3
end5 = InStr(start5, Source, "<", vbTextCompare)
len5 = end5 - start5
SearchR = Mid(Source, start5, len5)
LoopTimes = SearchR / 50
LoopTimes = Round(LoopTimes, 0)
A5 = True
End If
Rounds = Rounds + 1
Inter = Inter + 50
sort = "&skip=" & Inter
If Rounds = LoopTimes Then
SortListView ListView1, 3
Command1.Enabled = True
Exit Sub
Else
GoTo Loop2
End If
End If
End1:
SortListView ListView1, 3
Command1.Enabled = True
End Sub