Simple multiple form application
I have an application with two forms, FrmLogin and FrmMain. When application opens up, FrmLogin pops up for authentication, once successful, FrmMain should open and FrmLogin should close. Looks like I can not close the FrmLogin! Any idea? Thanks.
This is the code behind the Login Button. Unfortunately I can NOT close the FrmLogin once authentication is successful!
VB Code:
Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
If Me.TxtUsername.Text = "User” And Me.TxtPassword.Text = "password" Then
Dim form2 As New FrmMain
form2.Show()
Else
Me.Close()
End If
End Sub
Re: Simple multiple form application
Quote:
Originally posted by babakanoush
I have an application with two forms, FrmLogin and FrmMain. When application opens up, FrmLogin pops up for authentication, once successful, FrmMain should open and FrmLogin should close. Looks like I can not close the FrmLogin! Any idea? Thanks.
This is the code behind the Login Button. Unfortunately I can NOT close the FrmLogin once authentication is successful!
VB Code:
Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
If Me.TxtUsername.Text = "User” And Me.TxtPassword.Text = "password" Then
Dim form2 As New FrmMain
form2.Show()
Else
Me.Close()
End If
End Sub
The simple answer is set Sub Main of a Module as your startup object
In the Module:
VB Code:
Public frmLogin as New FormLogin
Public frm2 as New FrmMain
Public Sub Main()
frmLogin.ShowDialog()
frm2.ShowDialog()
End Sub