I have created a login that needs a text file with two words in it one on a line.
CODE
Private Sub Form_Load()
Dim MyName As String
Dim MyUName As String
Dim MyPass As String
Dim Response As Integer
Dim Saved_Name As String
Dim Saved_Pass As String
Dim Label2 As String
Open "\vb\login system\login.txt" For Input As #1
Line Input #1, Saved_Name
Line Input #1, Saved_Pass
Close #1
nFileNum = FreeFile
Login_Name:
MyName = InputBox("Please, enter Your name.", "Introduce yourself", "")
If MyName = "" Then
Response = MsgBox("To continue with logging on, you need to introduce yourself." & vbCrLf & "Do You wish to proceed with the programm?", vbCritical + vbYesNo, "Error")
If Response = vbYes Then GoTo Login_Name
If Response = vbNo Then
MsgBox "We are sorry you do not wish to proceed." & vbCrLf & "We wish you a good day", vbInformation + vbOKOnly, "End"
Label2 = MyName
End
End If
End If
Login_UName:
MyUName = InputBox("Good day " & MojeIme & ", please, enter your user name.", "Login", "")
If MyUName = "" Then
Response = MsgBox("To continue with logging on, you need to enter username." & vbCrLf & "Do You wish to proceed with the programm?", vbCritical + vbYesNo, "Error")
If Response = vbYes Then GoTo Login_UName
If Response = vbNo Then
MsgBox "We are sorry you do not wish to proceed." & vbCrLf & "We wish you a good day", vbInformation + vbOKOnly, "End"
End
End If
End If
Login_Pass:
MyPass = InputBox("Please, enter a password for user name " & MyUName & ".", "Password", "")
If MyPass = "" Then
Response = MsgBox("To continue with logging on, You need to enter your password." & vbCrLf & "Do You wish to proceed with the programm?", vbCritical + vbYesNo, "Error")
If Response = vbYes Then GoTo Login_Pass
If Response = vbNo Then
MsgBox "We are sorry you do not wish to proceed." & vbCrLf & "We wish you a good day", vbInformation + vbOKOnly, "End"
End
End If
End If
If (Saved_Name = MyUName) And (Saved_Pass = MyPass) Then
MsgBox "Good day " & MyName & "." & vbCrLf & "Thank you for logging on.", vbInformation + vbOKOnly, "Welcome"
Else
MsgBox "We are sorry, username and/or password are not correct", vbCritical + vbOKOnly, "Error"
End
End If
End Sub
'This is Open Source. Created By Sam Bennett