Strona: [  << <   1   > >>  ]  z  1     
Autor Temat: zrobienie projektu
..::DEMON::..




Typ: neutral
Postów: 28
Zarejestrowany: Jan 2004
zrobienie projektu

mam taki kod i mi niedziała pokazują sie błey może mi ktoś to zapisze do projektu i wyśle bo mi potrzebne. kod jest do wypełniania formularzy na www

'**************************************
' Name: Filling a form in the WebBrowser
'    Control (automatically)
' Description:Ever want to be able to au
'    tomate a web page process through a Visu
'    al Basic front end or form you've create
'    d? This code helps you control a web pag
'    e through the WebBrowser control to emul
'    ate actually entering data and submittin
'    g it through the web page itself. Check
'    it out. This code is from http://vbpoint
'    .cjb.net/ and there are more useful code
'    there also.
' By: Chris Kesler
'
' Assumes:In sample I will fill the Alta
'    vista search box, with the WebBrowser co
'    ntrol. Below I will list some subs and f
'    unctions which are used in this sample.
'    Open a new project (standard exe) and pl
'    ace a WebBrowser control, a textbox, and
'    a command button on form1.
'
'This code is copyrighted and has' limited warranties.Please see http://w
'    ww.Planet-Source-Code.com/vb/scripts/Sho
'    wCode.asp?txtCodeId=13439&lngWId=1'for details.'**************************************
'Add the following code To form1:


Private Sub Command1_Click()
    Dim doc As HTMLDocument 'Reference MSHTML.TLB - may End up being IHTMLDocument3
    'go to the altavista (text) search page
    WebBrowser1.Navigate "http://www.altavista.com/cgi-bin/query?text";
    'Wait until page is loaded


    Do


        DoEvents
        Loop Until Not WebBrowser1.Busy
        'Make doc reference to the document insi
        '    de the webbrowser control
        Set doc = WebBrowser1.Document
        'Set field q with the value of Text1
        SetInputField doc, 0, "q", Text1
        'Submit the form (same result as click t
        '    he search button)


        doc.Forms(0).submit
            'Wait until result are loaded


            Do


                DoEvents
                Loop Until Not WebBrowser1.Busy
                MsgBox "Altavista search result loaded"
            End Sub
Public Sub SetInputField()
Dim doc As HTMLDocument
Dim Form As Integer
Dim name As String
Dim Value As String
    'doc = HTMLDocument, can be retrieved
    ' from webbrowser --> webbrowser.docu
    '    ment
    'Form = number of the form
    ' (if only one form in the doc --> Fo
    '    rm = 0)
    'Name = Name of the field you would like
    '    to fill
    'Value = The new value for the input fie
    '    ld called name
    'PRE: Legal parameters entered
    'POST: Input field with name Name on for
    '    m Form in document doc will be filled wi
    '    th Value


    For q = 0 To doc.Forms(Form).length - 1


        If doc.Forms(Form)(q).name = name Then


            doc.Forms(Form)(q).Value = Value
                Exit For
            End If
        Next q
    End Sub
Public Function GetInputField() As String
Dim doc As HTMLDocument
Dim Form As Integer
Dim name As String

    For q = 0 To doc.Forms(Form).length - 1


        If doc.Forms(Form)(q).name = name Then
            GetInputField = doc.Forms(From)(q).Value
            Exit For
        End If
    Next q
End Function
'Sub to set a Checkbox:


Public Sub SetCheckBox()
Dim doc As HTMLDocument
Dim Form As Integer
Dim name As String
Dim Value As Boolean


    For q = 0 To doc.Forms(Form).length - 1


        If doc.Forms(Form)(q).name = name Then


            doc.Forms(From)(q).Checked = Value
                Exit For
            End If
        Next q
    End Sub
'Sub set a radio button:


Public Sub SetRadioButton()
Dim doc As HTMLDocument
Dim Form As Integer
Dim name As String
Dim Name2 As String

    For q = 0 To doc.Forms(Form).length - 1


        If (doc.Forms(Form)(q).name = name) And (doc.Forms(Form)(q).Value = Name2) Then


            doc.Forms(From)(q).Checked = True
                Exit For
            End If
        Next q
    End Sub
'Sub to make a selection in a ComboBox w
'    ith Option Values:


Public Function SetComboBoxValue()
Dim doc As IHTMLDocument3
Dim Form As Integer
Dim name As String
Dim Name2 As String
    Dim q, i


    For q = 0 To doc.Forms(Form).length - 1


        If (doc.Forms(Form)(q).name = name) Then


            For i = 0 To doc.Forms(Form)(q).length - 1


                If doc.Forms(Form)(q).Options(i).Value = Name2 Then


                    doc.Forms(Form)(q).Options(i).Selected = True
                        Exit For
                    End If
                Next i
            End If
        Next q
    End Function
    'Sub to make a selection in a ComboBox w
    '    ithout Option Values:


Public Function SetComboTextValue()
Dim doc As IHTMLDocument3
Dim Form As Integer
Dim name As String
Dim Name2 As String
    Dim q, i


    For q = 0 To doc.Forms(Form).length - 1


        If (doc.Forms(Form)(q).name = name) Then


            For i = 0 To doc.Forms(Form)(q).length - 1


                If doc.Forms(Form)(q).Options(i).Text = Name2 Then


                    doc.Forms(Form)(q).Options(i).Selected = True
                        Exit For
                    End If
                Next
            End If
        Next q
    End Function

16-02-2004 19:42
Pokaż profil ..::DEMON::..  Wyślij email do ..::DEMON::..   
anonim




Typ: Nie zarejestrowany

Też jestem tym zainteresowany. Jeśli mogę prosić kogoś o przesłanie projektu na .Z góry dziękuję!

16-02-2004 23:48
  
bisiek




Typ: neutral
Postów: 487
Zarejestrowany: Jul 2003

Wprowadź komponent Microsoft Internet Controls, wsadź jeden  na form, daj jeszcze commandbutton i textbox, nuie zmieniaj ich nazw. Teraz wpisz:

'**************************************
' Name: Filling a form in the WebBrowser
'    Control (automatically )
' Description:Ever want to be able to au
'    tomate a web page process through a Visu
'    al Basic front end or form you've create
'    d? This code helps you control a web pag
'    e through the WebBrowser control to emul
'    ate actually entering data and submittin
'    g it through the web page itself. Check
'    it out. This code is from http://vbpoint
'    .cjb.net/ and there are more useful code
'    there also.
' By: Chris Kesler
'
' Assumes:In sample I will fill the Alta
'    vista search box, with the WebBrowser co
'    ntrol. Below I will list some subs and f
'    unctions which are used in this sample.
'    Open a new project (standard exe) and pl
'    ace a WebBrowser control, a textbox, and
'    a command button on form1.
'
'This code is copyrighted and has' limited warranties.Please see http://w
'    ww.Planet-Source-Code.com/vb/scripts/Sho
'    wCode.asp?txtCodeId=13439&lngWId=1'for details.'**************************************
'Add the following code To form1:


Private Sub Command1_Click()
    Dim doc As HTMLDocument 'Reference MSHTML.TLB - may End up being IHTMLDocument3
    'go to the altavista (text) search page
    WebBrowser1.Navigate "http://www.altavista.com/cgi-bin/query?text";
    'Wait until page is loaded


    Do


        DoEvents
        Loop Until Not WebBrowser1.Busy
        'Make doc reference to the document insi
        '    de the webbrowser control
        Set doc = WebBrowser1.Document
        'Set field q with the value of Text1
        SetInputField doc, 0, "q", Text1
        'Submit the form (same result as click t
        '    he search button)


        doc.Forms(0).submit
            'Wait until result are loaded


            Do


                DoEvents
                Loop Until Not WebBrowser1.Busy
                MsgBox "Altavista search result loaded"
            End Sub
Public Sub SetInputField(doc As HTMLDocument, Form As Integer, name As String, Value As String)
'Dim doc As HTMLDocument
'Dim Form As Integer
'Dim name As String
'Dim Value As String
    'doc = HTMLDocument, can be retrieved
    ' from webbrowser --> webbrowser.docu
    '    ment
    'Form = number of the form
    ' (if only one form in the doc --> Fo
    '    rm = 0)
    'Name = Name of the field you would like
    '    to fill
    'Value = The new value for the input fie
    '    ld called name
    'PRE: Legal parameters entered
    'POST: Input field with name Name on for
    '    m Form in document doc will be filled wi
    '    th Value


    For q = 0 To doc.Forms(Form).length - 1


        If doc.Forms(Form)(q).name = name Then


            doc.Forms(Form)(q).Value = Value
                Exit For
            End If
        Next q
    End Sub
Public Function GetInputField() As String
Dim doc As HTMLDocument
Dim Form As Integer
Dim name As String

    For q = 0 To doc.Forms(Form).length - 1


        If doc.Forms(Form)(q).name = name Then
            GetInputField = doc.Forms(From)(q).Value
            Exit For
        End If
    Next q
End Function
'Sub to set a Checkbox:


Public Sub SetCheckBox()
Dim doc As HTMLDocument
Dim Form As Integer
Dim name As String
Dim Value As Boolean


    For q = 0 To doc.Forms(Form).length - 1


        If doc.Forms(Form)(q).name = name Then


            doc.Forms(From)(q).Checked = Value
                Exit For
            End If
        Next q
    End Sub
'Sub set a radio button:


Public Sub SetRadioButton()
Dim doc As HTMLDocument
Dim Form As Integer
Dim name As String
Dim Name2 As String

    For q = 0 To doc.Forms(Form).length - 1


        If (doc.Forms(Form)(q).name = name) And (doc.Forms(Form)(q).Value = Name2) Then


            doc.Forms(From)(q).Checked = True
                Exit For
            End If
        Next q
    End Sub
'Sub to make a selection in a ComboBox w
'    ith Option Values:


Public Function SetComboBoxValue()
Dim doc As IHTMLDocument3
Dim Form As Integer
Dim name As String
Dim Name2 As String
    Dim q, i


    For q = 0 To doc.Forms(Form).length - 1


        If (doc.Forms(Form)(q).name = name) Then


            For i = 0 To doc.Forms(Form)(q).length - 1


                If doc.Forms(Form)(q).Options(i).Value = Name2 Then


                    doc.Forms(Form)(q).Options(i).Selected = True
                        Exit For
                    End If
                Next i
            End If
        Next q
    End Function
    'Sub to make a selection in a ComboBox w
    '    ithout Option Values:


Public Function SetComboTextValue()
Dim doc As IHTMLDocument3
Dim Form As Integer
Dim name As String
Dim Name2 As String
    Dim q, i


    For q = 0 To doc.Forms(Form).length - 1


        If (doc.Forms(Form)(q).name = name) Then


            For i = 0 To doc.Forms(Form)(q).length - 1


                If doc.Forms(Form)(q).Options(i).Text = Name2 Then


                    doc.Forms(Form)(q).Options(i).Selected = True
                        Exit For
                    End If
                Next
            End If
        Next q
    End Function


_____________________________________________
www.mob.abc.pl - moja strona o VB

17-02-2004 19:51
Pokaż profil bisiek  Wyślij email do bisiek   Odwiedź stronę bisiek       3380672
bisiek




Typ: neutral
Postów: 487
Zarejestrowany: Jul 2003

Jeszcze trzeba dodać w Project/References plik Microsoft HTML Object Library


_____________________________________________
www.mob.abc.pl - moja strona o VB

17-02-2004 19:57
Pokaż profil bisiek  Wyślij email do bisiek   Odwiedź stronę bisiek       3380672
..::DEMON::..




Typ: neutral
Postów: 28
Zarejestrowany: Jan 2004

a ajk zrobić żeby się klikało na jakiś button lub żeby wysyłał enter

19-02-2004 10:00
Pokaż profil ..::DEMON::..  Wyślij email do ..::DEMON::..   
mailover




Typ: neutral
Postów: 40
Zarejestrowany: Mar 2003

Daj commandButton i pozycji Click
wpisz vbcr
Kliknięcie spowoduje wygenerowanie ENTERA
Zastosuj to gdzie potrzebujesz.
Np w transmisji przez comma 232:
mscomm1.output=vbcr

24-02-2004 15:57
Pokaż profil mailover  Wyślij email do mailover   
Wszystkich odpowiedzi: 5 :: Maxymalnie na stronę: 20
Strona: [  << <   1   > >>  ]  z  1