Please, I am having issues and needs help with the following code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close() 'Form2
Form3.showDialog()
End Sub
Report:
I have Form2 and Form3. With the above code, I intend to close Form2 and open Form3 (on button click). When I implemented the code, Form3 popped-up as expected but surprisingly few seconds after, the closed Form2 also popped-up. I believe "Me.Close" serves primarily to kill Form2 permanently. However, when I go to Project menu and set the Startup Form to start from Form2, everything works fine. But this would ignore Form1 which is the Welcome Page.
I have attempted using Me.Visible = False, dispose, and Me.Hide in place of “Me.Close” but all to no avail. I have also tried re-writing the code such that Form3.ShowDialog is written before Me.Close. I have also attempted using Form3.Show in place of "Form3.ShowDialog". Meanwhile, I also have set my Application Tab under Project properties to "When last form closes". Still, the closed Form still re-occurring.
The following is the code in Form1, could this be the cause?
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Interval = 10000
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Form2.Show()
Me.Hide()
End Sub
End Class
I am using Visual Studio 2015.
Form3.ShowDialog()line? - LarsTechYou have code somewhere else popping up a Form2- LarsTechTimer1.Stop()as the first line of theTimer1_Ticksub? - Andrew Morton