ExclamationSaving user data & reading the data HELP.

Posts 112 of 12 · Page 1 of 1
Saving user data & reading the data HELP.
I need someone that can actually code in VB to help me out here. I need help on how to save user data, and read them back. Add me in skype: mpghwhiskey so I can get help.
Quote Originally Posted by JimTheGreat View Post
I need someone that can actually code in VB to help me out here. I need help on how to save user data, and read them back. Add me in skype: mpghwhiskey so I can get help.
How do you want it to be saved and what are you saving?
Quote Originally Posted by DawgiiStylz View Post

How do you want it to be saved and what are you saving?
So basically when I open up my program, it will first ask me for my name, then a password I'd like to set as. Then, the program will open. But the next time I open this program, I don't want it to force me to create a new account each time I open it. The next time I open the program, I want it to save the name and the password, so that it asks me for the correct password, so then I can access it.
Quote Originally Posted by JimTheGreat View Post

So basically when I open up my program, it will first ask me for my name, then a password I'd like to set as. Then, the program will open. But the next time I open this program, I don't want it to force me to create a new account each time I open it. The next time I open the program, I want it to save the name and the password, so that it asks me for the correct password, so then I can access it.
Well, you could save it through the settings on the program, or write/read from a file
Quote Originally Posted by DawgiiStylz View Post

Well, you could save it through the settings on the program, or write/read from a file
Atm, I'm searching up ways of reading and writing to a file. I'll report back when I have another issue. Keep this thread open mods.
Quote Originally Posted by JimTheGreat View Post

Atm, I'm searching up ways of reading and writing to a file. I'll report back when I have another issue. Keep this thread open mods.
Try something like this

Code:
Public Function GetSettingItem(ByVal File As String, ByVal Identifier As String) As String
        Dim S As New IO.StreamReader(File)
        Dim Result As String = ""
        Do While (S.Peek <> -1)
            Dim Line As String = S.ReadLine
            If Line.ToLower.StartsWith(Identifier.ToLower) Then
                Result = Line.Substring(Identifier.Length)
            End If
        Loop
        Return Result
        S.Close()
    End Function

Dim string1, string2, string3 as string
Dim fileLoc As String = Application.StartupPath & "\Settings.txt"
    Private Sub LoadSettings()
        If My.Computer.FileSystem.FileExists(fileLoc) = False Then
            System****.File.Create(fileLoc)
        Else
            string1 = GetSettingItem(fileLoc, "<Data 1>")
            string2= GetSettingItem(fileLoc, "<Data 2>")
            string3 = GetSettingItem(fileLoc, "<Data 3>")
        End If
    End Sub


    Private Sub SaveSettings()
        If My.Computer.FileSystem.FileExists(fileLoc) = False Then
            System****.File.Create(fileLoc)
        Else
            Dim string1 = "<Data 1>"
            Dim string2 = "<Data 2>"
            Dim string3 = "<Data 3>"


            Dim writer As New System****.StreamWriter(fileLoc, False)
            writer.WriteLine(string1& TextBox1.Text)
            writer.WriteLine(string2 & TextBox2.Text)
            writer.WriteLine(string3 & TextBox3.Text)
            writer.Close()
        End If
    End Sub
Yea, text files work. I normally use text files since using my.settings normally gets deleted when the file is moved/copied to another location. Nice example, though don't forget some of it is blocked out
Quote Originally Posted by DawgiiStylz View Post

Try something like this

Code:
Public Function GetSettingItem(ByVal File As String, ByVal Identifier As String) As String
        Dim S As New IO.StreamReader(File)
        Dim Result As String = ""
        Do While (S.Peek <> -1)
            Dim Line As String = S.ReadLine
            If Line.ToLower.StartsWith(Identifier.ToLower) Then
                Result = Line.Substring(Identifier.Length)
            End If
        Loop
        Return Result
        S.Close()
    End Function

Dim string1, string2, string3 as string
Dim fileLoc As String = Application.StartupPath & "\Settings.txt"
    Private Sub LoadSettings()
        If My.Computer.FileSystem.FileExists(fileLoc) = False Then
            System****.File.Create(fileLoc)
        Else
            string1 = GetSettingItem(fileLoc, "<Data 1>")
            string2= GetSettingItem(fileLoc, "<Data 2>")
            string3 = GetSettingItem(fileLoc, "<Data 3>")
        End If
    End Sub


    Private Sub SaveSettings()
        If My.Computer.FileSystem.FileExists(fileLoc) = False Then
            System****.File.Create(fileLoc)
        Else
            Dim string1 = "<Data 1>"
            Dim string2 = "<Data 2>"
            Dim string3 = "<Data 3>"


            Dim writer As New System****.StreamWriter(fileLoc, False)
            writer.WriteLine(string1& TextBox1.Text)
            writer.WriteLine(string2 & TextBox2.Text)
            writer.WriteLine(string3 & TextBox3.Text)
            writer.Close()
        End If
    End Sub
Thanks for the code, but is there another way other than creating a file to store user data? Because then, people can just open the txt file and view the user account information and hack it.
If there really is no other way (not that I can think of), I can just encrypt the file, if that works.
Quote Originally Posted by JimTheGreat View Post

Thanks for the code, but is there another way other than creating a file to store user data? Because then, people can just open the txt file and view the user account information and hack it.
If there really is no other way (not that I can think of), I can just encrypt the file, if that works.
The file being saved is going to be on that user computer.
There other file types you can save it as, such as .xml files and other file types. Encryption is something you could add too
Quote Originally Posted by DawgiiStylz View Post

The file being saved is going to be on that user computer.
There other file types you can save it as, such as .xml files and other file types. Encryption is something you could add too
Thanks for the help. I'll report back with further results. Again, keep this thread open mods.
****'s = System. IO.
@Hero
Close this. Problem solved.
Posts 112 of 12 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?