Fill web form with VB .net

AndyAlexander

Newcomer
Joined
Jan 17, 2003
Messages
6
I'm trying to fill a simple web form in with vb .net, and have found numerous samples in VB6, however I can't seem to work out the same in vb .net.

I can add the explorer object and navigate to the page, however when I try to use the AxWebBrowser1.documents collection I don't have access to the 'all' or 'forms' objects that the VB6 examples uses.

Any help very gratefully received.

Andy
 
Have the same problem!

please post anything you know about this problem because
i have no further information and need one ...

mfG JPG
 
I don't have the same problem, using VB.NET and VS.NET 2003

AxWebBrowser.Document.all("fieldname").value = Value

However, if you are continuing to have problems, there is another option. I'm going to assume you are trying to POST data, since that requires a more advanced function.

Create a new System.Net.WebClient object.

Visual Basic:
Public Class MyWebClient
    Public Client As New System.Net.WebClient
    Public Function HTTPRequest(ByVal URL As String, ByVal postString As String, Optional ByVal Method As String = "POST") As String
        Dim serverResponse() As Byte
        Dim postBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(postString)
        Try
            serverResponse = Me.Client.UploadData(URL, Method, postBytes)
            ' Gets data from server!
        Catch ex As Exception

            MsgBox(ex.Message, MsgBoxStyle.Critical, ex.Source & " Error")
            Exit Function
        End Try
        Dim responseHTML As String = (System.Text.Encoding.ASCII.GetString(serverResponse))
        ' Turns server response(in bytes) into a string(HTML)
        Return responseHTML
    End Function
End Class

postString are your field arguments, the format for postString is as such

"fieldname=value&fieldname2=value2&ect=ect&ect=ect"
 
Back
Top