im trying to make a auto sign up in youtube but my problem is the " I accept" button doesnt have value in html so i try to use the id but i doesnt work help me please....

heres my code

Public Class Form1
    Public Sub BHMNavigate(ByRef Wb As WebBrowser, ByRef Url As String)
        Wb.Navigate(Url)
        Do While Wb.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        Loop
    End Sub
    Public Function FillOutForm(ByRef wb As WebBrowser, ByRef TagName As String, ByRef GetAttribute As String, ByRef ControlName As String, _
       ByRef SetAttribute As String, ByRef Value As String)

        Dim theElementCollection As HtmlElementCollection = wb.Document.GetElementsByTagName(TagName)

        For Each curElement As HtmlElement In theElementCollection
            Dim vcontrolName As String = curElement.GetAttribute(GetAttribute).ToString
            If vcontrolName = ControlName Then
                curElement.SetAttribute(SetAttribute, Value)
                Return 1
            End If
        Next
        Return 0
    End Function
    Public Sub ClickButton(ByRef wb As WebBrowser, ByRef value As String)
        'Submit button
        Dim theElementCollection As HtmlElementCollection
        theElementCollection = wb.Document.GetElementsByTagName("Input")
        For Each curElement2 As HtmlElement In theElementCollection
            If curElement2.GetAttribute("id").Equals(value) Then
                curElement2.InvokeMember("click")
                Do While wb.ReadyState <> WebBrowserReadyState.Complete
                    Application.DoEvents()
                Loop
            End If
        Next

    End Sub
    Public Sub ClickButton2(ByRef wb As WebBrowser, ByRef id As String)
        'Submit button
        Dim theElementCollection As HtmlElementCollection
        theElementCollection = wb.Document.GetElementsByTagName("Input")
        For Each curElement2 As HtmlElement In theElementCollection
            If curElement2.GetAttribute("id").Equals(id) Then
                curElement2.InvokeMember("click")
                Do While wb.ReadyState <> WebBrowserReadyState.Complete
                    Application.DoEvents()
                Loop
            End If
        Next

    End Sub
  
    Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
        BHMNavigate(WebBrowser1, "http://www.youtube.com/create_account?next=%2F")
        FillOutForm(WebBrowser1, "input", "id", "username", "value", "youtesttube")
        FillOutForm(WebBrowser1, "select", "id", "countrySelect", "value", "AU")
        FillOutForm(WebBrowser1, "select", "name", "birthday_mon", "value", "1")
        FillOutForm(WebBrowser1, "select", "name", "birthday_day", "value", "1")
        FillOutForm(WebBrowser1, "select", "name", "birthday_yr", "value", "1988")
        ClickButton(WebBrowser1, "male")
        ClickButton2(WebBrowser1, "button-signin")

Use this Sub or modify ClickButton2:

Public Sub ClickAHref(ByRef wb As WebBrowser, ByRef id As String)
        'Submit button
        Dim theElementCollection As HtmlElementCollection
        [B]theElementCollection = wb.Document.GetElementsByTagName("a")[/B]
        For Each curElement2 As HtmlElement In theElementCollection
            If curElement2.GetAttribute("id").Equals(id) Then
                curElement2.InvokeMember("click")
                Do While wb.ReadyState <> WebBrowserReadyState.Complete
                    Application.DoEvents()
                Loop
            End If
        Next

    End Sub

thanks for the reply men... but ive already solve this problem by sending it by form name...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.