hvordan får man flere resultater end kun højest 10...?
Til andre der læser med i denne tråd og vil prøve sig frem, vil jeg lige tilføje nogle ting i måske kan bruge:
Du skal bruge 4 knapper, 1 TekstBox, 1 ListBox og 1 CommonDialog.
I menuen Project > References, marker udfor Microsoft XML v2.6
Knappernes caption:
Command1 = Søg
Command2 = Ryd
Command3 = Fjern valgte
Command4 = Gem
Kode til søg knappen:
Private Sub Command1_Click()
Dim Text As String
GetHTTPSource ("http://www.google.com/search?q=" & Text1.Text), Text
ParseText Text
End Sub
Kode til ryd knappen:
Private Sub Command2_Click()
List1.Clear
End Sub
Kode til fjern valgte knappen:
Private Sub Command3_Click()
Dim a As Integer
For a = 0 To List1.ListCount - 1
recheck:
If a > List1.ListCount - 1 Then Exit Sub
If List1.Selected(a) = True Then
List1.RemoveItem (a)
GoTo recheck
End If
Next a
End Sub
Kode til gem knappen:
Private Sub Command4_Click()
CommonDialog1.InitDir = AppPath
CommonDialog1.ShowSave
If CommonDialog1.FileName & "" = "" Then
MsgBox "Du mangler at skrive et navn til filen", vbOKOnly, "Fejl"
Else
Close #1
Open CommonDialog1.FileName For Append As #1
For a = 0 To List1.ListCount
Print #1, List1.List(a)
Next a
Close #1
MsgBox "Fil gemt til " & CommonDialog1.FileName, vbOKOnly, "Færdig"
End If
End Sub
Koden til at parse teksten:
Private Sub ParseText(Text As String)
Dim Tmp As Variant
Dim Pos As Long
Dim X1 As Integer
Tmp = Split(Text, "<a class=l href=")
For X1 = 1 To UBound(Tmp)
Pos = InStr(2, Tmp(X1), Chr(34))
If Pos > 0 Then
List1.AddItem Mid(Tmp(X1), 2, Pos - 2)
End If
Next X1
End Sub
Koden til GetHTTPSource:
Private Function GetHTTPSource(ByVal URL As String, Text As String) As Long
Dim objHTTP As New XMLHTTP
objHTTP.open "GET", URL, False
objHTTP.send
If (objHTTP.Status = "200") Then
Text = objHTTP.responseText
GetHTTPSource = 0
Else
GetHTTPSource = 1
End If
Set objHTTP = Nothing
End Function
Kode til når man klikker på et link i listboxen:
Private Sub List1_Click()
ShellExecute List1.hwnd, vbNullString, List1.Text, vbNullString, "C:\\", SW_SHOWNORMAL
End Sub
Declarations:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Indlæg senest redigeret d. 25.11.2006 18:26 af Bruger #8719