Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 Need help with an error ASAP!

$
0
0
Hey guys, just joined this forum because I am receiving an error I just cannot solve, so hopefully someone can help me out:

Starting off here is my project and it has 3 Classes (this is just a new project I made to simulate the error, so there might be some useless things):

Form1:
Code:

Public Class Form1
    Dim suc As Boolean = False

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        registerNewForm.Show()
        BackgroundWorker1.RunWorkerAsync()
        Do Until suc = True
            Application.DoEvents()
        Loop

        suc = False
        GlobalVariable.registerNewFormDone = False
        Try
            BackgroundWorker1.CancelAsync()
            BackgroundWorker1.Dispose()
        Catch ex As Exception
        End Try
        MessageBox.Show("Success!")
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        While GlobalVariable.registerNewFormDone = False
            If GlobalVariable.retryRegisterBool = True Then
                GlobalVariable.retryRegisterBool = False
                registerNewForm.Show()
            End If
        End While
    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        suc = True
    End Sub
End Class


registerNewForm:
Code:

Imports System.IO
Imports System.Management
Imports System.Net

Public Class registerNewForm
    Public Shared done As Boolean = False
    Dim retry As Integer = 0
    Dim isCaptcha As Boolean = True
    Dim username As String = "username"
    Dim password As String = "password"
    Dim start As Integer = 1
    Dim email As String = "jugaloo132@aol.com"
    Dim bMonth As String = "02"
    Dim bDay As String = "14"
    Dim bYear As String = "1995"
    Dim saveTo As String = ""


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Stop()
        Threading.Thread.Sleep(50)
        WebBrowser1.Document.GetElementById("PvpnetAccountName").SetAttribute("value", username)    'Set GlobalVariable.UserName + Random Int
        WebBrowser1.Document.GetElementById("PvpnetAccountPassword").SetAttribute("value", password)    'Set GlobalVariable.PassWord
        WebBrowser1.Document.GetElementById("PvpnetAccountConfirmPassword").SetAttribute("value", password)  'Set GlobalVariable.PassWord
        WebBrowser1.Document.GetElementById("PvpnetAccountEmailAddress").SetAttribute("value", email)      ' Set GlobalVariable.UserName + Random Int + @gmail.com
        WebBrowser1.Document.GetElementById("PvpnetAccountDateOfBirthMonth").SetAttribute("value", bMonth)    'Set GlobalVariable.month
        WebBrowser1.Document.GetElementById("PvpnetAccountDateOfBirthDay").SetAttribute("value", bDay)        'Set GlobalVariable.Day
        WebBrowser1.Document.GetElementById("PvpnetAccountDateOfBirthYear").SetAttribute("value", bYear)    'Set GlobalVariable.Year
        Try
            WebBrowser1.Document.GetElementById("PvpnetAccountCaptcha").SetAttribute("value", Label1.Text)      'Set Catpcha
        Catch ex As Exception
        End Try
        WebBrowser1.Document.GetElementById("PvpnetAccountTouAgree").SetAttribute("checked", "checked")
        WebBrowser1.Document.GetElementById("PvpnetAccountNewsletter").InvokeMember("click")
        WebBrowser1.Document.GetElementById("AccountSubmit").InvokeMember("click")
        Timer2.Start()
    End Sub

    Private Sub registerNewForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Control.CheckForIllegalCrossThreadCalls = False
        done = False
        SetDesktopLocation(0, 0)
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If start = 1 Or retry = 1 Then
            WebBrowser1.Navigate("https://signup.leagueoflegends.com/en/signup/index")
            start = 2

            '    ElseIf retry = 5 Then
            'Threading.Thread.Sleep(2000)
            '    Try
            'WebBrowser1.Document.GetElementById("PvpnetAccountCaptcha").SetAttribute("value", Label1.Text)      'Set Catpcha
            '    Catch ex As Exception
            'isCaptcha = False
            '    End Try
            '    Button1.Enabled = True
            '    start = 3
            '    retry = 3
        End If

        If start = 3 Or retry = 3 Then
            start = 4
            retry = 4
            Timer1.Stop()
            Button1.PerformClick()
        End If

    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        BackgroundWorker1.RunWorkerAsync()
    End Sub

    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Timer2.Stop()
        Threading.Thread.Sleep(5000)
        '  MessageBox.Show(WebBrowser1.Url.ToString)
        If WebBrowser1.Url.ToString.Equals("https://signup.leagueoflegends.com/en/signup/index") Then
            checkCaptcha()
            BackgroundWorker1.CancelAsync()
            BackgroundWorker1.Dispose()
            GlobalVariable.retryRegisterBool = True
            Me.Close()
        Else
            BackgroundWorker1.CancelAsync()
            BackgroundWorker1.Dispose()
            GlobalVariable.retryRegisterBool = False
            GlobalVariable.registerNewFormDone = True
            done = True
            Me.Close()
        End If
    End Sub

    Private Function checkCaptcha()
        Try
            WebBrowser1.Document.GetElementById("PvpnetAccountCaptcha").SetAttribute("value", Label1.Text)      'Set Catpcha
        Catch ex As Exception
            isCaptcha = False
        End Try
        Button1.Enabled = True
        start = 3
        retry = 3
    End Function

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If start = 2 Or retry = 2 Then
            checkCaptcha()
        End If
    End Sub
End Class

and GlobalVariable:
Code:

Public Class GlobalVariable
    Public Shared registerNewFormDone As Boolean = False
    Public Shared retryRegisterBool As Boolean = False
End Class

Now what I am trying to achieve is once button1 is clicked in Form1 registerNewForm opens and trys to register an account, if the register failed (username is taken) it will close the form, and reopen and try again. Obviously in this example it will never succeed because it keeps trying the same thing over and over.

The error I receive is this:


In Form1


Any help on this error is greatly appreciated. Thanks!

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>