.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Advanced login form in vb.net

Posted By:laptop charles       Posted Date: July 04, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

Advanced login form.

First off all drag and drop the two text box and two label then three button.
The two text box name is  txtusername,Other one is txtpassword.
Three button name is btnnewuser,btnlogin,btncancel.
Button one is used to create account new user,other one is used to login then last one is used to clear the txt box.
Public Class Form1

    Private Sub btnnewuser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnewuser.Click
        If My.Computer.FileSystem.DirectoryExists("C:\CHARLES\") = True Then


        End If
        Dim cha As String
        Dim chuser As System.IO.StreamReader = New System.IO.StreamReader("C:\CHARLES\" + "username.txt")

        cha = chuser.ReadLine()
        If cha = txtusername.Text Then
            MsgBox("User name is already exist")
        ElseIf txtusername.Text = "" Then
            MsgBox("ERROR,Your account must have one letter in IT", MsgBoxStyle.Critical)
        ElseIf txtpassword.Text = "" Then
            MsgBox("ERROR,Please insert a password", MsgBoxStyle.Critical)

            'MkDir("C:\CHARLES\" + txtusername.Text)
            Dim username As New System.IO.StreamWriter("C:\CHARLES\" + "username.txt")
            'MkDir("C:\CHARLES\" + txtpassword.Text)
            Dim password As New System.IO.StreamWriter("C:\CHARLES\" + "password.txt")
            MsgBox("Account Created", MsgBoxStyle.Information, "ACCOUNTS CREATED")
        End If

    End Sub

    Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
        If txtusername.Text = "" Then
            MsgBox("ERROR,You neet At least one letter", MsgBoxStyle.Critical)
            If My.Computer.FileSystem.DirectoryExists("C:\CHARLES\") Then
                Dim userread As System.IO.StreamReader = New System.IO.StreamReader("C:\CHARLES\" + "username.txt")
                Dim userline As String
                Dim passread As System.IO.StreamReader = New System.IO.StreamReader("C:\CHARLES\" + "password.txt")
                Dim passline As String
                    passline = txtpassword.Text
                    userline = userread.ReadLine
                Loop Until userline Is Nothing

                If txtusername.Text = "" Then
                    MsgBox("ERROR,Please input a password", MsgBoxStyle.Critical)
                    If passline = passread.ReadLine() = True Then
                        MsgBox("WELCOME TO THE SYSTEM=" + txtusername.Text)

                    End If
                End If
                MsgBox("The user name don't exit", MsgBoxStyle.Critical)
            End If
        End If

    End Sub

    Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
        txtusername.Text = ""
        txtpassword.Text = ""
    End Sub
End Class


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend