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


Top 5 Contributors of the Month
david stephan

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

        Else
            MkDir("C:\CHARLES\")

        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)
        Else



            'MkDir("C:\CHARLES\" + txtusername.Text)
            Dim username As New System.IO.StreamWriter("C:\CHARLES\" + "username.txt")
            username.Write(txtusername.Text)
            username.Close()
            'MkDir("C:\CHARLES\" + txtpassword.Text)
            Dim password As New System.IO.StreamWriter("C:\CHARLES\" + "password.txt")
            password.Write(txtpassword.Text)
            password.Close()
            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)
        Else
            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
                Do
                    passline = txtpassword.Text
                    userline = userread.ReadLine
                    
                Loop Until userline Is Nothing

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

                    End If
                End If
            Else
                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:

Responses

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