-1

Okay, here is my code.

    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

On the line Form3.Show() I get

InvalidOperationException was unhandled.

An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.

What I have on 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

Any help?

Chris Dunaway
  • 10,974
  • 4
  • 36
  • 48
Wolfie
  • 51
  • 8
  • That means that your form was never created before..? Or maybe it is trying to show the form3 twice before it has time to close itself (as it should repeate every 1.75 seconds) Try to place this in your Timer1_Tick sub `Timer1.Stop()` at the beginning of the sub. Does that help? – Sifu Jul 24 '14 at 17:45
  • The code works . what code you have on form.3 ? – Creator Jul 24 '14 at 17:47
  • Adding Timer1.stop() at the beginning of the sub still throws the error. – Wolfie Jul 24 '14 at 18:00
  • What do you use for varible1 on form 4? – Creator Jul 24 '14 at 18:16
  • possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Sean Airey Jul 24 '14 at 18:17
  • @Sean This isn't a duplicate. – Wolfie Jul 24 '14 at 18:19
  • @Creator Its just a boolean that makes sure that the application loaded its requirements before activating that code :) – Wolfie Jul 24 '14 at 18:20
  • Please don't clear your question like that. It makes all the answers and comments seem nonsensical! – Chris Dunaway Jul 25 '14 at 13:52

1 Answers1

0

Change on form3

Public IPAddress As String = TextBox1.Text ...."TextBox1.Text is "" thats why you get the error"
To
Public IPAddress As String

End then add IPAddress = TextBox1.Text in you timer

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
Creator
  • 1,502
  • 4
  • 17
  • 30