我正在尝试打开表单并收到此错误

时间:2014-07-24 17:36:40

标签: vb.net forms

好的,这是我的代码。

    Public Class Form2


Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    ProgressBar1.Minimum = 0
    ProgressBar1.Maximum = 1000
    ProgressBar1.Value = 1000
    Timer1.Interval = 1750
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Form3.Show()
    Me.Close()
End Sub
End Class

Form3.Show()行上我得到了

InvalidOperationException未处理。

创建表单时出错。有关详细信息,请参阅Exception.InnerException。错误是:对象引用未设置为对象的实例。

我在Form3上有什么:

    Public Class Form3
Public IPAddress As String = TextBox1.Text
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Timer1.Interval = 1000
    Timer1.Enabled = True
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Form4.Show()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    If Form4.varible1 = True Then
        Label1.Text = "IP: " + IPAddress
    End If
End Sub
End Class

任何帮助?

1 个答案:

答案 0 :(得分:0)

表格3的变更

Public IPAddress As String = TextBox1.Text ...." TextBox1.Text is""这就是为什么你得到错误"
为了
公共IP地址为字符串

结束然后在你的计时器中添加IPAddress = TextBox1.Text

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

    If Form4.varible1 = True Then
        IPAddress = TextBox1.Text
        Label1.Text = "IP: " + IPAddress

    End If
End Sub