It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

VB Login Program wont login

Moderator: dafunkymunky

VB Login Program wont login

Postby deathy150 on Tue Feb 09, 2010 6:44 pm

Hi,

I am using VB 2008 Express Edition and i not long ago started a project on an accounts login project it was working fine for ages until i messed something up and it refuses to login to a new account. I have spent hours going through the code and have had not success in finding my little bug. I would greatly appreciate it if anyone could take a look at it and find the problem the code is below.

Code: Select all

Public Class Form1
    Dim contpass As Boolean 'Alow password to exist'
    Dim contuser As Boolean 'Alow username to exist'

    Private Sub btncreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncreate.Click

        If MaskedTextBox1.Text = MaskedTextBox3.Text Then
            If CheckBox1.Checked = True Then
                If My.Computer.FileSystem.DirectoryExists("C:\Accounts\") = True Then 'Checks if a derectory accounts folder exists'

                Else
                    MkDir("C\Accounts\") 'Else Creates accounts folder'
                End If
                If My.Computer.FileSystem.DirectoryExists("C:\Accounts\" + TextBox12.Text) = True Then 'Checks accounts avalibility'
                    MsgBox("Error, Account is already in use", MsgBoxStyle.Critical)
                    TextBox12.Clear()
                    MaskedTextBox1.Clear()
                Else
                    If TextBox12.TextLength <= 4 Then
                        MsgBox("Error, Your Account name must have at least 5 Characters", MsgBoxStyle.Information)
                        contuser = False
                        TextBox12.Clear()
                    Else
                        If MaskedTextBox1.TextLength <= 5 Then
                            MsgBox("Error, Input a password at a min of 6 characters", MsgBoxStyle.Information)
                            contpass = False
                            MaskedTextBox1.Clear()
                        ElseIf Not My.Computer.FileSystem.DirectoryExists("C:\Accounts\" + TextBox12.Text) = True Then
                            contpass = True
                            contuser = True
                        End If
                    End If
                End If
                If contpass And contuser = True Then
                    MkDir("C:\Accounts\" + TextBox12.Text)
                    Dim Username As New System.IO.StreamWriter("C:\Accounts\" + TextBox12.Text + "\" + "Username.txt")
                    Username.Write(TextBox12.Text)
                    Username.Close()
                    Dim Password As New System.IO.StreamWriter("C:\Accounts\" + TextBox12.Text + "\" + "Password.txt")
                    Password.Write(MaskedTextBox1.Text)
                    Password.Close()
                    If My.Computer.FileSystem.DirectoryExists("C:\Accounts\") = True Then
                        MsgBox("Your account has been made sucsessfuly, You can now login ", MsgBoxStyle.Information)
                        TextBox12.Clear()
                        MaskedTextBox1.Clear()
                        MaskedTextBox3.Clear()
                        CheckBox1.Checked = False
                    Else
                        MsgBox("You do not yet have an account")
                    End If
                End If
            Else
                MsgBox("You must agree to the terms of use ")
            End If
        Else
            MsgBox("The passwords you entered do not match ")
            MaskedTextBox3.Clear()
        End If
    End Sub

    Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click

        If My.Computer.FileSystem.DirectoryExists("C:\Accounts\" + TextBox1.Text + "\") = False Then
            Label6.Visible = True
            TextBox1.Clear()
            TextBox2.Clear()
            Timer1.Enabled = False


            If My.Computer.FileSystem.DirectoryExists("C:\Accounts\" + TextBox1.Text + "\") = True Then
                Dim Userread As System.IO.StreamReader = New System.IO.StreamReader("C:\Accounts\" + TextBox1.Text + "\")
                Dim Userline As String
                Dim Passread As System.IO.StreamReader = New System.IO.StreamReader("C:\Accounts\" + TextBox1.Text + "\")
                Dim Passline As String

                Do
                    Passline = TextBox2.Text()
                    Userline = Userread.ReadLine()
                    Console.WriteLine(Passline)
                    Console.WriteLine(Userline)
                Loop Until Userline Is Nothing


                MsgBox("Welcome to The System " + TextBox1.Text + "!")
                Label6.Visible = False
                TextBox1.Clear()
                TextBox2.Clear()
                Form2.Show()
            End If
        End If
    End Sub

    Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
        Dialog1.Show()
    End Sub

    Private Sub btnexit2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit2.Click
        End
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        End
    End Sub

    Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
        TextBox1.Copy()
    End Sub

    Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
        TextBox1.Paste()
    End Sub

    Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
        TextBox1.Cut()
    End Sub

    Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoToolStripMenuItem.Click
        TextBox1.Undo()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label6.Visible = False
        TextBox2.PasswordChar = ("*")
        TextBox3.PasswordChar = ("*")
        TabControl1.SelectedTab = TabPage1
        TextBox2.PasswordChar = ("*")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TabControl1.SelectedTab = TabPage1

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim strComputerName As String
        strComputerName = Environment.GetEnvironmentVariable("COMPUTERNAME")
        If TextBox3.Text = strComputerName And MaskedTextBox2.Text = "199520002006" Then
            Form2.Show()
            MsgBox("Welcome admin! ", MsgBoxStyle.Information)
            TextBox3.Clear()
            MaskedTextBox2.Clear()
        Else
            MsgBox("Incorrect password ", MsgBoxStyle.Critical)
            TextBox3.Clear()
            MaskedTextBox2.Clear()
            If TextBox2.Text = Text Then
                MsgBox("The characters in the verifacation box are not numeric! ", MsgBoxStyle.Critical)
            End If
            If TextBox2.TextLength > 8 Then
                MsgBox("The PassKey is too long ")
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        If My.Computer.FileSystem.DirectoryExists("C:\Accounts\" + TextBox12.Text) = True Then 'Checks accounts avalibility'
            Timer2.Enabled = True
            If Timer2.Enabled = True Then
                Label4.Visible = True
                Label5.Visible = False
                TextBox12.Clear()
            End If
        Else
            Timer2.Enabled = False
            If Timer2.Enabled = False Then
                Label5.Visible = True
                Label4.Visible = False
            End If
        End If
    End Sub
End Class




Thanks Craig :wink:
deathy150
 
Posts: 1
Joined: Tue Feb 09, 2010 6:35 pm

Who is online

Users browsing this forum: No registered users and 2 guests