used to be cmdShowForm and cmdHideForm what is it now?

I am using the VB 2005 Beta program and I know the routines for VB6.
In VB6 a command button could be put on a form and then code written/added to
get from one form to another;

the old code was cmdShowForm and to to hide the form: cmdHideForm

frmSecondForm.Show

et cetera

but VB 2005 is different; can you advise me as to what the new code for
VB 2005 is


Answer this question

used to be cmdShowForm and cmdHideForm what is it now?

  • raindrops123

    I think your problem is that as forms are treated as classes you need to instantiate an instance to use it.

    So if you have a form with a name FrmMain as an example.

    To display it you would do something like

    Dim Main as new Frmmain
    Main.Show  or Main.ShowDialog

    For a command button to hide the current form you can use something like

    me.hide    or me.close


    If you want to close one form from another you will need a reference on the first form to the second form.

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim o As New Form2
    o.ShowDialog()

    If o.DialogResult = True Then
       
    o.Close()
    End If

    End Sub
    End
    Class

    and on Form2

    Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Me.Hide()
    End Sub

    End
    Class

    This would allow you to display an instance of form2 as a modal dialog and when you click the button on form2 it would hide and the button would be set to return a dialogreturn of OK.    When the return value of OK is received back to form1 it would close form2

    Form1 has a reference to the instance of form2


  • vivi_0606

    Hi,

    I think its still the same.The only main difference is showing modal dialogs.

    Me.Show() - vbModeless in VB6
    Me.ShowDialog() - vbModal
    Me.Hide() - Hides the form

     

    cheers,

    Paul June A. Domag



  • used to be cmdShowForm and cmdHideForm what is it now?