Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System
- Imports System.IO
- Public Class Form1
- Dim password, username, newpass, newuser As String
- Dim valid As Boolean = False
- Dim fileread As String
- Structure passwordRec
- Dim RecUname As String
- Dim RecPword As String
- End Structure
- Dim SingleRec As passwordRec
- Sub checkvalid()
- 'read in password
- password = txtPassword.Text
- 'read in username
- username = txtUsername.Text
- 'open file
- FileOpen(1, CurDir() & "/user.txt", OpenMode.Input)
- 'read from file
- While Not EOF(1)
- Input(1, SingleRec.RecUname)
- Input(1, SingleRec.RecPword)
- 'checking credentials against the record
- If username = SingleRec.RecUname And password = SingleRec.RecPword Then
- valid = True
- End If
- If valid Then
- MsgBox("Correct")
- Me.Close()
- Else
- MsgBox("Incorrect")
- Me.Close()
- End If
- End While
- FileClose(1)
- End Sub
- Function register(user, pass) As String
- FileOpen(1, CurDir() & "/user.txt", OpenMode.Append)
- ' user.replace("""", "")
- ' pass.replace("""", "")
- WriteLine(1, user, pass)
- FileClose(1)
- End Function
- Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- End Sub
- Private Sub btnLogin_Click(sender As System.Object, e As System.EventArgs) Handles btnLogin.Click
- checkvalid()
- End Sub
- Private Sub btnRegister_Click(sender As System.Object, e As System.EventArgs) Handles btnRegister.Click
- newuser = InputBox("Enter username")
- newpass = InputBox("Enter password")
- register(newuser, newpass)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement