Switching Between Forms

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2009
Posts: 19
Reputation: OldQBasicer is an unknown quantity at this point 
Solved Threads: 0
OldQBasicer OldQBasicer is offline Offline
Newbie Poster

Switching Between Forms

 
0
  #1
Oct 23rd, 2009
I want to use more than one form in my project and be able to code a button or something that will do that. I tried this on Form1 and it worked.

  1. Public Class Form1
  2.  
  3. Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  4. 'Goes from this form to form 2
  5. My.Forms.Form2.Show()
  6. End Sub
  7.  
  8. End Class

BUT then I tried the following on Form2 to go back to Form1 and it doesn't work... the button does nothing.

  1. Public Class Form2
  2.  
  3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4. My.Forms.Form1.Show() 'Doesn't work
  5.  
  6. End Sub
  7. End Class
Also, when the user switches to a different form, will the variables assigned on the first form still be assigned on the second form (assuming they're declared as Public in the module?
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 94
Reputation: yorro has a little shameless behaviour in the past 
Solved Threads: 6
yorro yorro is offline Offline
Junior Poster in Training
 
0
  #2
Oct 24th, 2009
Form1
Button Event
Me.Hide
Form2.Show


Form2
Button Event
Me.Hide
Form1.Show
Last edited by yorro; Oct 24th, 2009 at 5:33 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 19
Reputation: OldQBasicer is an unknown quantity at this point 
Solved Threads: 0
OldQBasicer OldQBasicer is offline Offline
Newbie Poster
 
0
  #3
Oct 24th, 2009
Got it. Thanks.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 259 | Replies: 2
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC