Loading and unloading forms

Hi,
I am new to VB.Net.

I have a sub main which has code:

Public Sub Main()
Dim frmNewLogin As frmLogin
Dim frmNewMain As New frmMain()
Dim frmNewadmin As New frmAdmin()
Dim frmNewLauncher As New frmLauncher()

frmNewLogin = New frmLogin()
frmNewMain = New frmMain()
frmNewadmin = New frmAdmin()
frmNewLauncher = New frmLauncher()
frmNewLogin.Show()
End Sub




I have a frmLogin with code:


Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim frmNewMain As New frmMain()
frmNewMain.Show()
Me.Hide()
End Sub



I have a frmMain in which, when user clicks Logoff, I want frmMain closed and frmLogin show.
In frmMain, I have,

Private Sub mnuLogoff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuLogOff.Click

Me.Close()
End Sub

But here, I get error at Me.Close()
"Name 'frmNewLogin' is not set."
What can I do?

Thanks in advance.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories