Articles

Solved VB 2010 Login form

November 29, 2012 at 06:26:22
Specs: Windows 7

how to create a login form using for loop and class and the date are stored in note.txt
example
when the user enter a name and password the program will check if that user is existing or not .

Thanks


See More: VB 2010 Login form

Report •


✔ Best Answer
December 6, 2012 at 13:18:18

Have you tried setting a breakpoint and single-stepping your way though? It might give you a better understanding of your code.

That said . . .
Dim user As New clsLogin
If user.strUser_Type = "Administrator" Then

Why are you using user instead of All_Users(i)?

How To Ask Questions The Smart Way



#1
December 2, 2012 at 14:01:26

Hi i see No one Answer so I try to solve it myself but didn't go anywhere here is my code if u can try to fix it or tell me where did i go wrong ^^ just give me a clue
or the logic for it so i can move on

Public Class frmLogin
    Dim Loginusers As New List(Of Login)
    Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
        Dim user As New Login

        If txtusername.Text = user.strUser_Name Then
            If txtPassword.Text = user.strPassword Then
                If user.strUser_Name = user.blnUser_Type = "Administrator" Then
                    Me.Hide()
                    frmLibraryAdmin.Show()
                Else
                    Me.Hide()
                    frmLibraryRegular.Show()
                End If
            Else
                MsgBox("PLease Enter A Correct Password")
            End If
        Else
            MsgBox("Please Enter A correct User Name")
        End If

    End Sub

    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim loginformation As New System.IO.StreamReader("LogInfo.txt")

        While Not loginformation.EndOfStream
            Dim user As New Login

            user.strEmployee_name = loginformation.ReadLine
            user.strEmployee_ID = loginformation.ReadLine
            user.blnUser_Type = loginformation.ReadLine
            user.strUser_Name = loginformation.ReadLine
            user.strPassword = loginformation.ReadLine

            Loginusers.Add(user)
        End While
        loginformation.Close()
    End Sub
End Class

edited by moderator: Added pre tags -Razor2.3


Report •

#2
December 4, 2012 at 21:11:26

Without spending too much time looking at your code, I suggest you look into For Each.

How To Ask Questions The Smart Way


Report •

#3
December 6, 2012 at 11:53:00

thanx but i dont know how to use for each so i tried for next loop it work but only send me to form3 not form2 even if i enter the right user name and password here is the new code that i wrote

                For i = 0 To All_Users.Count - 1
                    If txtusername.Text = All_Users(i).strUser_Name Then
                        AdminFound = True
                        If txtPassword.Text = All_Users(i).strPassword Then
                            Dim user As New clsLogin
                            If user.strUser_Type = "Administrator" Then
                                Me.Hide()
                                frmAdmin.Show()
                            Else
                                Me.Hide()
                                frmRegular.Show()
                            End If
                        Else
                            MsgBox("Incorrect Password !! :P ")
                        End If
                    End If
                Next
                If AdminFound = False Then
                    MsgBox("Incorrect User Name XD ")
                End If

edited by moderator: Added pre tags -Razor2.3


Report •

Related Solutions

#4
December 6, 2012 at 13:18:18
✔ Best Answer

Have you tried setting a breakpoint and single-stepping your way though? It might give you a better understanding of your code.

That said . . .
Dim user As New clsLogin
If user.strUser_Type = "Administrator" Then

Why are you using user instead of All_Users(i)?

How To Ask Questions The Smart Way


Report •

#5
December 8, 2012 at 03:48:20

thanx man u really helped me ^^

Report •


Ask Question