-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login.vb
107 lines (87 loc) · 3.93 KB
/
Login.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Public Class frmLogin
'MOUSE---------------------------------------------------------------------------------------------------------------
Private Sub frmOrders_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
'-Mouse Control via Keyboard
If e.Control And e.KeyCode = Keys.Left Then 'Ctrl+Left Moves Cursor Left
Cursor.Position = New Point(Cursor.Position.X - 10, Cursor.Position.Y)
End If
If e.Control And e.KeyCode = Keys.Right Then 'Ctrl+Right Moves Cursor Right
Cursor.Position = New Point(Cursor.Position.X + 10, Cursor.Position.Y)
End If
If e.Control And e.KeyCode = Keys.Up Then 'Ctrl+Up Moves Cursor Up
Cursor.Position = New Point(Cursor.Position.X, Cursor.Position.Y - 10)
End If
If e.Control And e.KeyCode = Keys.Down Then 'Ctrl+Down Moves Cursor Down
Cursor.Position = New Point(Cursor.Position.X, Cursor.Position.Y + 10)
End If
End Sub
'/MOUSE--------------------------------------------------------------------------------------------------------------
Dim Count As Integer = 0
Public Drive As String = "C:\Slice\"
Structure LoginType
<VBFixedString(20)> Dim User As String '20
<VBFixedString(20)> Dim Password As String '20
End Structure '=40
Dim Login As LoginType
Dim FileName As String
Dim TableFormat As String = "{0,-20}{1,-20}"
Dim User As String
Dim Password As String
Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'set the filename
FileName = Drive & "\Settings.txt"
'open the file
FileOpen(1, FileName, OpenMode.Random, , , Len(Login))
'check the user and pass in file
Do While Not EOF(1)
FileGet(1, Login.User)
FileGet(1, Login.Password)
Loop
'close the file
FileClose(1)
User = Login.User
Password = Login.Password
End Sub
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
Dim Unlock As Boolean
'Unlocks application
If txtUser.Text = User And txtPass.Text = Password Then 'Usual access details
Unlock = True
imgUnlock.Visible = True
imgLock.Visible = False
tmrCorrect.Enabled = True
'Debug
Debug.Print(vbNewLine & "Access Granted")
ElseIf txtUser.Text = "Admin" And txtPass.Text = "abc123" Then 'Allows entry for Administrator if usual password forgotten
Unlock = True
imgUnlock.Visible = True
imgLock.Visible = False
tmrCorrect.Enabled = True
'Debug
Debug.Print(vbNewLine & "Access Granted")
Else 'Failed Login
Count = Count + 1
imgUnlock.Visible = False
imgLock.Visible = True
lblCount.Text = Count
MessageBox.Show("Username or Password Incorrect", "Message", MessageBoxButtons.OK)
End If
'Closes Program
If Count = 3 Then
End
End If
End Sub
Private Sub tmrCorrect_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrCorrect.Tick
'Debug
Debug.Print("Entering Control Interface")
'Shows password protected application
frmSplash.Show()
MyBase.Hide()
tmrCorrect.Enabled = False
End Sub
Private Sub frmLogin_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Enter Then
cmdLogin.PerformClick()
End If
End Sub
End Class