Vb.net Remember me(login form).flv

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • This is could be useful in vb.net applications that require the "Remember me" function.
    Here is the code
    Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If TextBox1.Text = My.Settings.username And TextBox2.Text = My.Settings.password Then
    MsgBox("Access granted", vbInformation)
    Else
    MsgBox("Details incorrect", vbExclamation)
    End If
    End Sub
    Private Sub ShowDetailsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ShowDetailsToolStripMenuItem.Click
    MsgBox("Username is: " + My.Settings.username + " Password is: " + My.Settings.password, vbInformation)
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    End
    End Sub
    Private Sub AddUserToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AddUserToolStripMenuItem.Click
    If CheckBox1.Checked = True Then
    My.Settings.check = True
    Else
    My.Settings.check = False
    End If
    My.Settings.username = TextBox1.Text
    My.Settings.password = TextBox2.Text
    My.Settings.Save()
    TextBox1.Text = ""
    TextBox2.Text = ""
    TextBox1.Focus()
    MsgBox("Added", vbInformation)
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    If My.Settings.check = True Then
    TextBox1.Text = My.Settings.username
    TextBox2.Text = My.Settings.password
    Else
    'do nothing
    End If
    End Sub
    End Class
    I will be more than willing to send you the project and also assist with any other projects and assignments within my know :D

Komentáře • 2