Manesti
Member
- Joined
- Jan 16, 2009
- Messages
- 16
- Programming Experience
- Beginner
I have 2 forms in my project. I want a case where by a user can click a log out button and the main form is disabled while, the login form shows. But if I try to log in again and enable the main form, this does not work.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim login As New Login
' Me.Enabled = False 'disables the main form
login.ShowDialog()
Label18.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim userlevel As String
'log in using name and password
If txtuser.Text = "" Or txtpass.Text = "" Then
MsgBox("Enter Full Log in Details")
Return
End If
userlevel = UserLogIn(txtuser.Text, txtpass.Text)
counter = userLogCount()
If userlevel <> "" Then
If counter > 1 Then
Me.Hide()
main.Enabled = True
Exit Sub
End If
Me.Hide()
'check user privilege and disable features
If userlevel = "regular" Then
main.Label58.Enabled = False
main.Label9.Enabled = False
main.Label10.Enabled = False
main.Label4.Enabled = False
main.Label55.Enabled = False
End If
main.Show()
Else
'wrong password
MessageBox.Show("Wrong User Name or Password, Contact Admin.", "Log In", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
counter = counter + 1
txtuser.Text = ""
txtpass.Text = ""
End If
logcount(counter)
End Sub
Private Sub logcount(ByVal number As Integer)
If number >= 3 Then
MsgBox("Maximum Try, Contact Admin")
Me.Close()
End If
End Sub