对象引用未设置为对象错误的实例?

时间:2015-08-31 11:18:12

标签: vb.net

每当我尝试启动程序时,我都会收到此错误。这是我的代码:

Imports System.IO

Public Class Form1
    Dim Passwords As New ArrayList
    Dim fileReader As String
    Dim WB As WebBrowser = Form2.WebBrowser1
    Dim Username As String = ThirteenTextBox1.Text

    Private Sub ThirteenButton2_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
        Passwords.Clear()
        NP.Text = Passwords.Count & " passwords loaded."
    End Sub

    Private Sub LoadButton_Click(sender As Object, e As EventArgs) Handles LoadButton.Click
        FileDialog.ShowDialog()
    End Sub

    Private Sub FileDialog_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles FileDialog.FileOk
        Dim sr As New StreamReader(FileDialog.FileName)
        Do While sr.Peek >= 0
            Passwords.Add(sr.ReadLine())
            NP.Text = Passwords.Count & " passwords loaded."
        Loop
        sr.Close()
        sr.Dispose()
    End Sub

    Private Sub NP_Click(sender As Object, e As EventArgs) Handles NP.Click

    End Sub

    Private Sub ThirteenForm1_Click(sender As Object, e As EventArgs) Handles ThirteenForm1.Click

    End Sub

    Private Sub ThirteenButton5_Click(sender As Object, e As EventArgs) Handles ThirteenButton5.Click
        Form2.Visible = True
    End Sub

    Private Sub ThirteenButton4_Click(sender As Object, e As EventArgs) Handles ThirteenButton4.Click
        WB.Navigate("http://roblox.com/game/logout.aspx")
        Delay(4)
        WB.Navigate("https://www.roblox.com/Login/iFrameLogin.aspx")
        Delay(7)
        Dim UsernameField = WB.Document.GetElementById("UserName")
        Dim PasswordField = WB.Document.GetElementById("Password")
        Dim LoginButton = WB.Document.GetElementById("LoginButton")
        For Each Password As String In Passwords
            UsernameField.SetAttribute("Value", Username)
            PasswordField.SetAttribute("Value", Password)
            If WB.Document.GetElementById("recaptcha_challenge_image") IsNot Nothing Then
                Form3.Visible = True
                Console.WriteLine("Captcha detected!")
                Form3.PictureBox1.ImageLocation = WB.Document.GetElementById("recaptcha_challenge_image").GetAttribute("src")
                While Variables.Clicked = False
                    Application.DoEvents()
                End While
                Variables.Clicked = False
                Form3.PictureBox1.ImageLocation = ""
                WB.Document.GetElementById("recaptcha_response_field").SetAttribute("Value", Form3.ThirteenTextBox1.Text)
            End If
            LoginButton.InvokeMember("click")
            Delay(3)
            If UsernameField Is Nothing Then
                MessageBox.Show("Password is " & Password)
                Stop
            End If
        Next
    End Sub
End Class

1 个答案:

答案 0 :(得分:0)

我已经解决了,问题是我试图做Dim Username as String = TextBox1.Text