minifranki
Messages postés23Date d'inscriptionvendredi 10 mars 2006StatutMembreDernière intervention 4 juin 2008
-
3 juin 2008 à 07:42
minifranki
Messages postés23Date d'inscriptionvendredi 10 mars 2006StatutMembreDernière intervention 4 juin 2008
-
3 juin 2008 à 14:34
Bonjour,
Le formulaire ne se rempli pas lorsque je test et jobtient un erreur de debug quand il est temps denvoyer mon formulaire. Je ne sais vraiment plus quoi faire. Voici mon code(il nest pas toute la):
WebBrowser1.Navigate(siteweb2.Text)
Do
Application.DoEvents()
Loop Until Not WebBrowser1.IsBusy
Dim MyForm As MSHTML.HTMLFormElement
MyForm = RemplirInputText(WebBrowser1.Document, "INPUTTEXT", "Coucou")
MyForm = RemplirTextArea(WebBrowser1.Document, "TEXTAREA", "J'espere que ca marche")
MyForm = RemplirInputPass(WebBrowser1.Document, "INPUTPASS", "SuperPasswordQuiTue")
MyForm = RemplirInputCheckBox(WebBrowser1.Document, "INPUTCK", "2", True)
MyForm = RemplirInputRadio(WebBrowser1.Document, "INPUTRD", "2", True)
MyForm = RemplirInputHidden(WebBrowser1.Document, "INPUTHID", "TEXSTEST")
MyForm.submit()
End Sub
Public Function RemplirInputText(ByRef doc As HtmlDocument, ByVal InputName As String, ByVal Value As String) As MSHTML.HTMLFormElement
'Parametre en entree :
' - doc = HTMLDocument en provenance du WebBrowser
' - InputName = Nom du champs de type input
' - Value = Valeur a mettre dans le champs
'Parametre en Sortie :
' - Fomrulaire contenant le champ pour le submit
On Error Resume Next
Dim d As MSHTML.HTMLObjectElement
Dim minput As MSHTML.HTMLInputTextElement
For Each d In doc.All
Application.DoEvents()
For Each minput In d.All
Application.DoEvents()
If minput.tagName = "INPUT" Then If minput.Name InputName And UCase(Trim(minput.Type)) "TEXT" Then
minput.Value = Value
RemplirInputText = minput.Form
Exit Function
End If
End If
Next
Next
End Function
Public Function RemplirInputPass(ByRef doc As HtmlDocument, ByVal InputName As String, ByVal Value As String) As MSHTML.HTMLFormElement
'Parametre en entree :
' - doc = HTMLDocument en provenance du WebBrowser
' - InputName = Nom du champs de type input
' - Value = Valeur a mettre dans le champs
'Parametre en Sortie :
' - Fomrulaire contenant le champ pour le submit
On Error Resume Next
Dim d As MSHTML.HTMLObjectElement
Dim minput As MSHTML.HTMLInputTextElement
For Each d In doc.All
Application.DoEvents()
For Each minput In d.All
Application.DoEvents()
If minput.tagName = "INPUT" Then If minput.Name InputName And UCase(Trim(minput.Type)) "PASSWORD" Then
minput.Value = Value
RemplirInputPass = minput.Form
Exit Function
End If
End If
Next
Next
End Function
Public Function RemplirInputHidden(ByRef doc As HtmlDocument, ByVal InputName As String, ByVal Value As String) As MSHTML.HTMLFormElement
'Parametre en entree :
' - doc = HTMLDocument en provenance du WebBrowser
' - InputName = Nom du champs de type input
' - Value = Valeur a mettre dans le champs
'Parametre en Sortie :
' - Fomrulaire contenant le champ pour le submit
On Error Resume Next
Dim d As MSHTML.HTMLObjectElement
Dim minput As MSHTML.HTMLInputTextElement
For Each d In doc.All
Application.DoEvents()
For Each minput In d.All
Application.DoEvents()
If minput.tagName = "INPUT" Then If minput.Name InputName And UCase(Trim(minput.Type)) "HIDDEN" Then
minput.Value = Value
RemplirInputHidden = minput.Form
Exit Function
End If
End If
Next
Next
End Function
Public Function RemplirInputRadio(ByRef doc As HtmlDocument, ByVal InputName As String, ByVal InputName2 As String, ByVal Value As Boolean) As MSHTML.HTMLFormElement
'Parametre en entree :
' - doc = HTMLDocument en provenance du WebBrowser
' - InputName = Nom du champs de type input
' - InputName2 = Valeur contenu dans Value du champs !
' - Value = Valeur a mettre dans le champs
'Parametre en Sortie :
' - Fomrulaire contenant le champq pour le submit
On Error Resume Next
Dim d As MSHTML.HTMLObjectElement
Dim minput As MSHTML.HTMLInputTextElement
For Each d In doc.All
Application.DoEvents()
For Each minput In d.All
Application.DoEvents()
If minput.tagName = "INPUT" Then If minput.Name InputName And minput.Value InputName2 And UCase(Trim(minput.Type)) = "RADIO" Then
minput.Checked = Value
RemplirInputRadio = minput.Form
Exit Function
End If
End If
Next
Next
End Function
Public Function RemplirTextArea(ByRef doc As HtmlDocument, ByVal InputName As String, ByVal Value As String) As MSHTML.HTMLFormElement
'Parametre en entree :
' - doc = HTMLDocument en provenance du WebBrowser
' - InputName = Nom du champs de type TextArea
' - Value = Valeur a mettre dans le champs
'Parametre en Sortie :
' - Fomrulaire contenant le champ pour le submit
On Error Resume Next
Dim d As MSHTML.HTMLObjectElement
Dim minput As MSHTML.HTMLTextAreaElement
For Each d In doc.All
Application.DoEvents()
For Each minput In d.All
Application.DoEvents()
If minput.tagName = "TEXTAREA" Then
If minput.Name = InputName Then
minput.Value = Value
RemplirTextArea = minput.Form
Exit Function
End If
End If
Next
Next
End Function
Public Function RemplirInputCheckBox(ByRef doc As HtmlDocument, ByVal InputName As String, ByVal InputName2 As String, ByVal Value As Boolean) As MSHTML.HTMLFormElement
'Parametre en entree :
' - doc = HTMLDocument en provenance du WebBrowser
' - InputName = Nom du champs de type input
' - InputName2 = Valeur contenu dans Value du champs !
' - Value = Valeur a mettre dans le champs
'Parametre en Sortie :
' - Fomrulaire contenant le champq pour le submit
On Error Resume Next
Dim d As MSHTML.HTMLObjectElement
Dim minput As MSHTML.HTMLInputTextElement
For Each d In doc.All
Application.DoEvents()
For Each minput In d.All
Application.DoEvents()
If minput.tagName = "INPUT" Then If minput.Name InputName And minput.Value InputName2 And UCase(Trim(minput.Type)) = "CHECKBOX" Then
minput.Checked = Value
RemplirInputCheckBox = minput.Form
Exit Function
End If
End If
Next
Next