我是 Visual Basic 2010 编程新手。我遇到以下错误:
Microsoft.VisualBasic.dll 中出现了“System.InvalidCastException”类型的第一次机会异常
这是我的代码。
Public Class Form1
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If TextBox2.ReadOnly = True Then
TextBox2.ReadOnly = False
End If
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If TextBox3.ReadOnly = False Then
TextBox3.ReadOnly = True
TextBox3.Text = "|n/a|"
End If
If TextBox2.ReadOnly = False Then
TextBox2.ReadOnly = True
End If
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
TextBox3.Text = "[1.5.2]"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If CheckBox1.Checked Then
Button1.Enabled = False
Threading.Thread.Sleep(500)
Button2.PerformClick()
Button3.PerformClick()
Button4.PerformClick()
Threading.Thread.Sleep(500)
If RichTextBox1.Text = Nothing Then
Threading.Thread.Sleep(5000)
Button3.PerformClick()
Button3.PerformClick()
Label4.Text = "Next try in 10 seconds"
Threading.Thread.Sleep(10000)
Label4.Text = "Trying...."
Button1.Enabled = True
Button1.PerformClick()
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TabControl1.SelectedTab = TabPage2
Threading.Thread.Sleep(1000)
WebBrowser2.Navigate("https://login.minecraft.net?user=" + TextBox1.Text + "&password=" + TextBox2.Text + "&version=13")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
RichTextBox1.Text = WebBrowser2.DocumentText
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If WebBrowser2.DocumentText.Contains("Bad login") Then
MessageBox.Show("Bad login!")
End If
If WebBrowser2.DocumentText.Contains("User not premium") Then
MessageBox.Show("User not premium! Please buy Minecraft at the http://minecraft.net/ ")
End If
If RichTextBox1.Text.Contains("Bad login") Then
MessageBox.Show("Bad login!")
End If
If RichTextBox1.Text.Contains("User not premium") Then
MessageBox.Show("User not premium! Please buy Minecraft at the http://minecraft.net/ ")
End If
End Sub
End Class