944,010 Members | Top Members by Rank

Ad:
Oct 22nd, 2009
0

Switching Between Forms

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
OldQBasicer is offline Offline
38 posts
since Oct 2009
Oct 22nd, 2009
0
Re: Switching Between Forms
What is the purpose of the Class?

Form1 button = fomr1.Hide, Form2.show

Form2 button = Form2.hide, Form1.Show
Reputation Points: 33
Solved Threads: 27
Posting Whiz
Jupiter 2 is offline Offline
372 posts
since May 2009
Oct 23rd, 2009
0
Re: Switching Between Forms
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
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: cd database
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Railway Reservation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC