VB6 在模块中声明 webbrowser

VB6 declare webbrowser in module

我是 VB6 的新手,我有一个使用网络浏览器建立互联网连接的项目。制作它的功能在下面描述的模块中,项目在主窗体中调用它。

表格:

Private Sub Form_Load()
    Me.Top = 585
    Me.Left = 12090

    Call BuscaPais.Paises(48, -1)
End Sub

模块 BuscaPais:

Sub Paises(clifor, tempodia)

    Dim db As New ADODB.Connection
    db.Open "Driver={MySQL ODBC 3.51 Driver};Uid=root;Pwd=03072003;Server=xxx.xxx.xx.xx;Port=xxx;Option=xxx;STMT=;Database=xxx"

    SQL = "select cd_ocorrencia, vl_latitude, vl_longitude from ocorrencias where dt_hora >= date_format(date_add(current_timestamp, interval " & tempodia & " day), '%Y/%m/%d') "
    SQL = SQL & " and cd_status <> 99 and ds_pais = '' and vl_latitude <> '0.000000' and vl_longitude <> '0.000000' order by cd_ocorrencia asc "
    Set RS = db.Execute(SQL)
    While Not RS.EOF

        WB.Navigate2 "http://nominatim.openstreetmap.org/reverse?format=xml&lat=" & Replace(RS!vl_latitude, ",", ".") & "&lon=" & Replace(RS!vl_longitude, ",", ".") & "&zoom=18&addressdetails=1"
        t = Timer
        Do Until WB.ReadyState = READYSTATE_COMPLETE
            checktime = Timer - t
            If checktime >= 30 Then
                WB.Stop
                DoEvents
            End If
            DoEvents
        Loop


        If InStr(WB.Document.body.innertext, "A página XML não pode ser exibida") = 0 Then
            Pais = UCase(Mid(WB.Document.body.innertext, InStr(WB.Document.body.innertext, "</country_code>") - 2, 2))
            db.Execute ("update ocorrencias set ds_pais = '" & Pais & "' where cd_ocorrencia = " & RS!cd_ocorrencia)
        End If

        Pais = ""

    RS.MoveNext
    Wend
    RS.Close

End Sub

returns WB.Navigate2 行中的一个错误 Object Required。如果我将这个函数放在 Forms 中,它就可以正常工作。如何在模块内声明一个网络浏览器?我尝试使用 Dim WB as New WebBrowser_V1 但我收到另一个错误:Object doesn't support this property or method

我只参考了主窗体就解决了:

Sub Paises(clifor, tempodia)

    Dim db As New ADODB.Connection
    db.Open "Driver={MySQL ODBC 3.51 Driver};Uid=root;Pwd=03072003;Server=xxx.xxx.xx.xx;Port=xxx;Option=xxx;STMT=;Database=xxx"

    SQL = "select cd_ocorrencia, vl_latitude, vl_longitude from ocorrencias where dt_hora >= date_format(date_add(current_timestamp, interval " & tempodia & " day), '%Y/%m/%d') "
    SQL = SQL & " and cd_status <> 99 and ds_pais = '' and vl_latitude <> '0.000000' and vl_longitude <> '0.000000' order by cd_ocorrencia asc "
    Set RS = db.Execute(SQL)
    While Not RS.EOF

        mainform.WB.Navigate2 "http://nominatim.openstreetmap.org/reverse?format=xml&lat=" & Replace(RS!vl_latitude, ",", ".") & "&lon=" & Replace(RS!vl_longitude, ",", ".") & "&zoom=18&addressdetails=1"
        t = Timer
        Do Until mainform.WB.ReadyState = READYSTATE_COMPLETE
            checktime = Timer - t
            If checktime >= 30 Then
                mainform.WB.Stop
                DoEvents
            End If
            DoEvents
        Loop


        If InStr(mainform.WB.Document.body.innertext, "A página XML não pode ser exibida") = 0 Then
            Pais = UCase(Mid(mainform.WB.Document.body.innertext, InStr(mainform.WB.Document.body.innertext, "</country_code>") - 2, 2))
            db.Execute ("update ocorrencias set ds_pais = '" & Pais & "' where cd_ocorrencia = " & RS!cd_ocorrencia)
        End If

        Pais = ""

    RS.MoveNext
    Wend
    RS.Close

End Sub