Results 1 to 9 of 9

Thread: Loginform

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Location
    Denmark
    Posts
    132

    Question Loginform

    Can anyone help me with the loginform?

    How do i set username and password, and how do i make a function that makes it aviable to change the password and the username from the program??
    Last edited by Eldrup; May 20th, 2009 at 03:19 PM. Reason: More text !
    Eldrup

  2. #2
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: Loginform

    Have you checked out the CodeBank yet There all kinds of samples of pretty much any thing you could need in there.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Location
    Denmark
    Posts
    132

    Re: Loginform

    I'll Try
    Eldrup

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Location
    Denmark
    Posts
    132

    Re: Loginform

    Hmm...Well i cant find anything?
    Eldrup

  5. #5
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Loginform

    Hmm...Well i cant find anything?
    You should probably look harder. There's several examples on validating login information and at least one on a login form.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  6. #6
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: Loginform

    You tried for what? 4 minutes.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  7. #7
    Hyperactive Member
    Join Date
    Apr 2009
    Posts
    358

    Re: Loginform

    You could Create a listbox object
    Code:
    Dim User as new Listbox
    Then set up a location to save the items of the listbox, and see if the listbox contains your username, then use another listbox with passwords, and then make it where the password listbox.selectedindex is equal to the second listboxes.selected index.

  8. #8
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: Loginform

    Quote Originally Posted by Eldrup View Post
    Can anyone help me with the loginform?

    How do i set username and password, and how do i make a function that makes it aviable to change the password and the username from the program??
    Ok, i used save setting for change password. i mean at form login you can create 2 label . 1 for pass and that one for user name.

    And when textboxpass and textboxusername change you assign of these value textboxs for labels. Finally when login form close you can save it to setting and when form load you can load it. exp :

    Code:
    Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.
            SaveSetting(Application.ProductName, Application.ProductName, "Label1", Label1.Text)
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ' Get checkbox value
            Label1.Text = GetSetting(Application.ProductName, Application.ProductName, "Label1", "")
        End Sub
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  9. #9
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: Loginform

    If you want you can use StreamReader and StreamWriter also, although it is simplistic set up this way and only allows one user, it shows you the steps required. Create a new project; add a new form, 2 text boxes, 2 labels, 4 buttons, a folder called TextFiles, a text document called simpleLogin.txt and name them the same as in the code.
    Name:  SimpleLogin.JPG
Views: 1148
Size:  12.5 KB
    Code:
    Public Class frmSimpleLogin
        Private Sub frmSimpleLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim sr As New IO.StreamReader("..\..\TextFiles\simpleLogin.txt")
            Dim userName As String = sr.ReadLine
            Dim password As String = sr.ReadLine
    
            If userName = String.Empty AndAlso password = String.Empty Then
                Me.btnCreateLogin.Visible = True
                Me.btnCreateLogin.Enabled = True
                MessageBox.Show("Please create a username and password.")
                ' keep other buttons disabled and invisible until username and password are created 
                Me.btnLogin.Visible = False
                Me.btnLogin.Enabled = False
                Me.btnChange.Visible = False
                Me.btnChange.Enabled = False
            End If
        End Sub
    
        Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
            Dim sr As New IO.StreamReader("..\..\TextFiles\simpleLogin.txt")
            Dim userName As String = sr.ReadLine
            Dim password As String = sr.ReadLine
            sr.Close()
            If Me.txtUserName.Text = String.Empty Then
                MessageBox.Show("You must enter a username.")
                Me.txtUserName.Select()
            ElseIf txtPassword.Text = String.Empty Then
                MessageBox.Show("You must enter a password.")
                Me.txtPassword.Select()
            ElseIf Me.txtUserName.Text = userName AndAlso Me.txtPassword.Text = password Then
                MessageBox.Show("You successfully logged in.")
                ' Enable the change button only if login is successful
                Me.btnChange.Visible = True
                Me.btnChange.Enabled = True
                ' do what ever else you want to do here after login is successful
            Else
                MessageBox.Show("Wrong username or password.")
                Me.clear()
            End If
            Me.clear()
        End Sub
    
        Private Sub btnCreateLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateLogin.Click
            Me.createChangeLogin()
        End Sub
    
        Private Sub btnChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChange.Click
            Me.createChangeLogin()
        End Sub
    
        Public Sub clear()
            Me.txtUserName.Clear()
            Me.txtPassword.Clear()
            Me.txtUserName.Select()
        End Sub
    
        Public Sub createChangeLogin()
            Dim sw As New IO.StreamWriter("..\..\TextFiles\simpleLogin.txt")
            If Me.txtUserName.Text = String.Empty Then
                MessageBox.Show("You must enter a username.")
                Me.txtUserName.Select()
            ElseIf txtPassword.Text = String.Empty Then
                MessageBox.Show("You must enter a password.")
                Me.txtPassword.Select()
            End If
            sw.Write(txtUserName.Text & Environment.NewLine)
            sw.Write(txtPassword.Text)
            sw.Close()
            Me.clear()
        End Sub
    
        Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
            Me.Close()
        End Sub
    End Class
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width