What can i have done with my form
- Hi
No matter what i do, if i in form1 write me.hide
or if i in form2 write form1.hide
this don't work my form 1 is allways on show
ALK
Answers
You can't hide a Form before it's shown. I assume the Form2.Show() code is in the Load event of Form1. Use Form2.ShowDialog();
- Marked As Answer byAlvin Kuiper Saturday, November 07, 2009 6:46 PM
All Replies
- Try this
form.visible = false
this will work - Hmm i use this:
Dim ab As StreamReader = New StreamReader(Application.StartupPath & "/play.txt") valg = Trim(ab.ReadLine) If valg = "" Then Me.Visible = False Form2.Show() End IfI can see my form 2 , but also Form1
And in form 2 i try using:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Form1.Visible = False End SubBut still i can see my form1
ALK - First, I think the slash in your path is the wrong one. Use "\"
-dave You can't hide a Form before it's shown. I assume the Form2.Show() code is in the Load event of Form1. Use Form2.ShowDialog();
- Marked As Answer byAlvin Kuiper Saturday, November 07, 2009 6:46 PM
if that's not working, can you post the entire Sub where the streamreader is?
because this should work
On Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "" Then Form2.Show() Me.Hide() End If End Sub
on Form2Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Form1.ShowDialog() End Sub
- And one other unsolicited tip...
You need to properly close your stream object after use. I find the easiest way is to use the Using block, like this:
I think John has hit the nail on the head... in the Load event your form is not visible yet. So You may want to move this code into the Form1.Shown event (which happens only after the first time the form becomes visible). Also, consider placing a Me.Refresh call after Me.Visible = False to ensire that the changes are affected before Form2 is shown.Using ab As New StreamReader(Application.StartupPath & "\play.txt") valg = Trim(ab.ReadLine) If valg = "" Then Me.Visible = False Form2.Show() End If End Using
- Thanks
ALK


