Show / Hide Form in VB.NET

How to show and hide form in VB.NET?

Explanation

Show / Hide Forms

Form in Visual Basic.net 2008 are displayed and hidden using two different methods.To display a form the Show() method is used and to hide a form Hide() method is used.
Show Method:

This method is used to display the form on top of all other windows even if it is loaded or not loaded into the memory.
Syntax:

FormName.Show
or
FormName.Show(1,)

In the above syntax, the Show method can also have argument values 0 or 1 for Modeless or Modal forms. By default this methods modeless or normal forms, but the modal forms more interactive.
Hide Method:

This method hides a form object from the screen, still with the object being loaded in the memory.
Syntax:

FormName.Hide
Example:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
DisplayForm.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button2.Click
DisplayForm.Hide()
End Sub
End Class
Description:

In the above example, two forms Form1, Form2 are used. An image is added to Form2 using the the click event of Button1 and Button2 the form is shown or hidden. Thus you can show or hide the forms.

Visual Basic Tutorial


Ask Questions

Ask Question