VB.NET - Logging into a website through vb

Discussion in 'Programming' started by jondouglas, May 25, 2009.

  1. #1
    Hi i've been trying to login into reddit at the click of a button. I've managed to fill the fields but I can't work out how to make it submit. Can anyone help?

    This is what I have:-

    
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    
            Dim username As String
            Dim password As String
            username = "username"
            password = "password"
    
            WebBrowser1.Document.GetElementById("user_login").SetAttribute("Value", username)
            WebBrowser1.Document.GetElementById("passwd_login").SetAttribute("Value", password)
    
            Dim theElementCollection As HtmlElementCollection = Me.WebBrowser1.Document.GetElementsByTagName("input")
    
            For Each curElement As HtmlElement In theElementCollection
                If curElement.GetAttribute("value").Equals("Login") Then
                    curElement.InvokeMember("click")
                End If
            Next
    
        End Sub
    
    Code (markup):
    Thanks for any help! :)
     
    jondouglas, May 25, 2009 IP
  2. felluahill

    felluahill Peon

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think you're supposed to invoke "submit" not "click."
     
    felluahill, May 25, 2009 IP