CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Posts
    18

    Switch between froms.

    Hi~~

    try to switch between different forms in my code, but how do I close my first form once I open the second form?

    the following is my code, can anyone tell me where I did wrong?


    Private Sub btnForm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForm2.Click
    Dim frmForm2 As New frmForm2()
    Dim frmForm1 As New frmForm1()


    frmForm2.Show()
    frmForm1.Hide()
    End Sub

    Thank you for your help .

  2. #2
    Join Date
    Feb 2003
    Posts
    51
    You may want to use the Close function for forms. This seems to work.

  3. #3
    Join Date
    Feb 2003
    Location
    Bilbao
    Posts
    513
    You can use Load to load a form into memory and Unload to unload it... Show to show a form (if it is not load, it loads), and Hide to hide it (but still in memory unless using unload).

    You cannot use the code above, because you are creating a new instance for frmForm1 and frmForm2.

    Try just with

    Private Sub Command1_Click()
    Form2.Show
    Form3.Hide
    End Sub

    Private Sub Command2_Click()
    Form3.Show
    Form2.Hide
    End Sub
    Caronte
    Si tiene solución... ¿por qué te preocupas?
    Si no tiene solución... ¿por qué te preocupas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured