Passing the password from form to another form

Viewed 44

I have been tasked to generate a password, and then pass it to another form to login

Public Class Form2

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim password As String
        Dim str0 As String
        Dim str1 As String
        Dim str2 As String

        password = txt_fname.Text.Substring(0, 1)
        str0 = txt_fname.Text

        password = password + txt_fname.Text.Substring(0, 1)
        str1 = txt_fname.Text

        password = password + txt_lname.Text.Substring(0, 1)
        str2 = txt_lname.Text

        str0 = str0.Length
        str1 = str1.Length
        str2 = str2.Length

        MsgBox(password & str0 & str1 & str2, MsgBoxStyle.Information)
            
        Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If txt_username.Text = "" Then
            MsgBox("Kindly Enter Your Username!", MsgBoxStyle.Exclamation, "Empty Username")
        ElseIf txt_password.Text = "" Then
            MsgBox("Kindly Enter Your Password!", MsgBoxStyle.Exclamation, "Empty Password")
        Else
            If txt_username.Text <> "Admin" Then
                MsgBox("Incorrect Username", MsgBoxStyle.Critical, "Username not Found")
                txt_username.Clear()
                txt_username.Focus()
                txt_password.Clear()
            ElseIf txt_password.Text <> "Admin" Then
                MsgBox("Incorrect Password", MsgBoxStyle.Critical, "Wrong Password")
                txt_password.Clear()
                txt_password.Focus()
            Else
                Form2.Show()
                Me.Hide()
                txt_username.Clear()
                txt_password.Clear()

            End If


        End If

    End Sub
0 Answers
Related