|
-
Oct 20th, 2009, 09:38 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Creating a new account on my login problem
hi guys ,
Ive created a new login system with a "create a new account" option , but when i debug it and create a new account and then login its works fine , but when i debug it again it wont remember the account ive just created . heres my code:
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If My.Computer.FileSystem.DirectoryExists(" C:\ACCOUNTS" + TextBox1.Text + "\") Then
Dim USERREAD As System.IO.StreamReader = New System.IO.StreamReader("C:\ACCOUNTS" + TextBox1.Text + "\" + "USERNAME.TXT")
Dim userline As String
Dim PASSREAD As System.IO.StreamReader = New System.IO.StreamReader("C:\ACCOUNTS" + TextBox1.Text + "\" + "PASSWORD.TXT")
Dim PASSLINE As String
Do
PASSLINE = TextBox2.Text
userline = USERREAD.ReadLine
Console.WriteLine(PASSLINE)
Console.WriteLine(userline)
Loop Until userline Is Nothing
Me.Hide()
Form2.ShowDialog()
If TextBox2.Text = "" Then
MsgBox("Error, PLEASE CHOOSE A PASSWORD", MsgBoxStyle.Critical)
Else
If PASSLINE = PASSREAD.ReadLine() = True Then
End If
End If
Else
MsgBox("THE USERNAME DONT EXIST", MsgBoxStyle.Critical)
End If
-
Oct 20th, 2009, 09:50 AM
#2
Hyperactive Member
Re: Creating a new account on my login problem
Don't really understand your code but I'll give it a go:
I don't see a textfile being created in your code? Are you doing this somewhere else? If you are, make sure you don't create the text file everytime the program starts. If a textfile already exists and you use system.io.file.createtext() then it will just overwrite it and your textfile will be empty again.
Last edited by gonzalioz; Oct 20th, 2009 at 09:54 AM.
-
Oct 20th, 2009, 09:57 AM
#3
Thread Starter
Fanatic Member
Re: Creating a new account on my login problem
here is the full code m8 ,
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("ERROR,Your Account/Username must have one letter in it!", MsgBoxStyle.Critical)
Else
If TextBox2.Text = "" Then
MsgBox("ERROR,Your Account/Password must have one letter in it!", MsgBoxStyle.Critical)
Else
MkDir("C:\ACCOUNTS" + TextBox1.Text)
Dim username As New System.IO.StreamWriter("C:\ACCOUNTS" + TextBox1.Text + "\" + "username.txt")
username.Write(TextBox1.Text)
username.Close()
Dim password As New System.IO.StreamWriter("C:\ACCOUNTS" + TextBox1.Text + "\" + "password.txt")
password.Write(TextBox2.Text)
password.Close()
MsgBox("ACCOUNT CREATED", MsgBoxStyle.Information, "ACCOUNT CREATED")
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If My.Computer.FileSystem.DirectoryExists(" C:\ACCOUNTS" + TextBox1.Text + "\") Then
Dim USERREAD As System.IO.StreamReader = New System.IO.StreamReader("C:\ACCOUNTS" + TextBox1.Text + "\" + "USERNAME.TXT")
Dim userline As String
Dim PASSREAD As System.IO.StreamReader = New System.IO.StreamReader("C:\ACCOUNTS" + TextBox1.Text + "\" + "PASSWORD.TXT")
Dim PASSLINE As String
Do
PASSLINE = TextBox2.Text
userline = USERREAD.ReadLine
Console.WriteLine(PASSLINE)
Console.WriteLine(userline)
Loop Until userline Is Nothing
Me.Hide()
Form2.ShowDialog()
If TextBox2.Text = "" Then
MsgBox("Error, PLEASE CHOOSE A PASSWORD", MsgBoxStyle.Critical)
Else
If PASSLINE = PASSREAD.ReadLine() = True Then
End If
End If
Else
MsgBox("THE USERNAME DONT EXIST", MsgBoxStyle.Critical)
End If
End Sub
End Class
-
Oct 20th, 2009, 10:08 AM
#4
Hyperactive Member
Re: Creating a new account on my login problem
That is a mystery!
Not yet discovered anything wrong but there's one thing:
("C:\ACCOUNTS" + TextBox1.Text + "\"
Shouldn't there be another backslash between ACCOUNTS and Textbox1.text?
-
Oct 20th, 2009, 10:18 AM
#5
Thread Starter
Fanatic Member
Re: Creating a new account on my login problem
im not sure m8 , ive tried that >> ("C:\ACCOUNTS\" + TextBox1.Text + "\"
but still the same
-
Oct 20th, 2009, 10:26 AM
#6
Hyperactive Member
Re: Creating a new account on my login problem
I am sorry can't help you any further .
I copied your code into a new project on my pc and it works fine! I added a msgbox("login succesful" between
If PASSLINE = PASSREAD.ReadLine() = True Then
End If
to check if it worked and it did. Also when I quitted the app and ran it again :S.
Edit:
I deleted the line form2.showdialog. Because I didn't have a form2 on my pc of course. Maybe there is going something wrong there?
-
Oct 20th, 2009, 10:35 AM
#7
Thread Starter
Fanatic Member
Re: Creating a new account on my login problem
ok m8 , thanks for your help anyway
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|