Switching Between Forms

Please support our Visual Basic 4 / 5 / 6 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 22nd, 2009
I want tu 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.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  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.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  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: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz
 
0
  #2
Oct 22nd, 2009
What is the purpose of the Class?

Form1 button = fomr1.Hide, Form2.show

Form2 button = Form2.hide, Form1.Show
If ALL my answers are wrong, only then will I read the question
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 916
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 167
vb5prgrmr vb5prgrmr is offline Offline
Posting Shark
 
0
  #3
Oct 23rd, 2009
OldQ, for future reference you are using .NET code and are presently in the wrong forum. You need to post your Q's in the .NET forum...

In vb6 there are two different ways to accomplish what you want. One is setfocus and the other is zorder.



Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Reply

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




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



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC