Form Loading..
-
Ok, my situation is like this. I have two forms in my application (Form1 and Form2), and on each form, I have one button (button1). I put the following code in button1 for Form1. "Dim frm2 as new Form2" "frm2.show()" and in Button1 of Form2 "Dim frm1 as new Form1" "frm1.show()" I noticed that if I clicked on these buttons a couple of times, multiple Form1 and Form2 gets created. Anyway to avoid this, like maybe when I click Form1 Button1, it closes the Form1 and opens Form2 and vice versa..?
-
Ok, my situation is like this. I have two forms in my application (Form1 and Form2), and on each form, I have one button (button1). I put the following code in button1 for Form1. "Dim frm2 as new Form2" "frm2.show()" and in Button1 of Form2 "Dim frm1 as new Form1" "frm1.show()" I noticed that if I clicked on these buttons a couple of times, multiple Form1 and Form2 gets created. Anyway to avoid this, like maybe when I click Form1 Button1, it closes the Form1 and opens Form2 and vice versa..?
icowa wrote: when I click Form1 Button1, it closes the Form1 and opens Form2 and vice versa I think u dont need to close form1 and open form2 and vice versa... u can let 2 forms are opened concurrently. below is just my suggestion: - In each form, u have a variable (boolean), named as isActive to store the status of the other form (this will be initialized as false, that means form2 is not activating), ie: when click form1 button1, the code should be as below: "Dim frm2 as new Form2" "if isActive then " //form2 is being actived " frm2.active()" "else " //form2 has not been showed yet "isActive = true" "frm2.show()" and certainlly, before form2 is closed, u need to set isActive = false in form1 and do the same thing for form2 << >>
-
Ok, my situation is like this. I have two forms in my application (Form1 and Form2), and on each form, I have one button (button1). I put the following code in button1 for Form1. "Dim frm2 as new Form2" "frm2.show()" and in Button1 of Form2 "Dim frm1 as new Form1" "frm1.show()" I noticed that if I clicked on these buttons a couple of times, multiple Form1 and Form2 gets created. Anyway to avoid this, like maybe when I click Form1 Button1, it closes the Form1 and opens Form2 and vice versa..?
I'm not sure if I got it correctly..... if you want to have a single form1 and form2 then the solution is not to re-declare them inside the procedure but just once at the beginning of the code. Thay way you are going to recall always the same one without creating a new instance.
-
I'm not sure if I got it correctly..... if you want to have a single form1 and form2 then the solution is not to re-declare them inside the procedure but just once at the beginning of the code. Thay way you are going to recall always the same one without creating a new instance.
-
How do you go about doing that? Any help that you can offer will be greatly appreciated... Thanz
My point is to move the declaration outside the form. A way of accomplishing it could be the following. Create a module with a Sub Main (it has to be the starting sub of the project Module xyz public F1 as new Form1 public F2 as new Form2 public sub Main F1.Show while F1 is not nothing application.doevents() wend end sub and then for each form/button event private sub Button1_Click(..) F1.Hide (F2.Hide in the other form) F2.Show (F1.Show in the other form) end sub Remember to unload Form1 to end the application
-
My point is to move the declaration outside the form. A way of accomplishing it could be the following. Create a module with a Sub Main (it has to be the starting sub of the project Module xyz public F1 as new Form1 public F2 as new Form2 public sub Main F1.Show while F1 is not nothing application.doevents() wend end sub and then for each form/button event private sub Button1_Click(..) F1.Hide (F2.Hide in the other form) F2.Show (F1.Show in the other form) end sub Remember to unload Form1 to end the application