locked
Program first open and saving data when program is closed RRS feed

  • Question

  •  

    Hello everyone, me again :P

     

    I am currently working on a menu driven console program that so far has 4 menu options of checking internet connection, decrypting/encrypting a message, calculator, and a logout, and i am wondering about a few current things.

     

    1. How do i make it to where, when a program starts for the first time, it asks for a user to enter in his data, like signing up for a site for the first time?

     

    2. How do i make it to where the program will save the data entered, and does not delete when the user closed the program.

     

    3. How can i make it to where when a user signs in, his/her data is read correctly? Like an array search for a multidimensional array.

     

    For my "New user" sign data i created a function...

     

    Function createNewUser() As String()
    
            Dim name As String
            Dim userName As String
            Dim password As String = ""
            Dim passwordCover As Char
    
    
            Console.Write("Please enter your name: ")
            name = Console.ReadLine()
            Console.Clear()
    
            Console.Write("Please enter you desired user name: ")
            userName = Console.ReadLine()
            Console.Clear()
    
            Console.WriteLine("Please enter you desired password: ")
            Do
                passwordCover = Console.ReadKey(True).KeyChar
                If passwordCover = Chr(8) And password.Length > 0 Then
                    Console.Write(vbBack & " " & vbBack)
                    password = password.Substring(0, password.Length - 1)
                ElseIf passwordCover > Chr(32) Then
                    Console.Write("*")
                    password = password & passwordCover
                End If
            Loop Until passwordCover = Chr(13)
    
            Console.Clear()
    
            Dim userInfo() As String = New String() {name, userName, password}
    
            Console.WriteLine("System is storing your data. Please wait...")
            System.Threading.Thread.Sleep(3000)
            Console.Clear()
    
            Return userInfo
    
        End Function
    

     

     

    4. Changing a user's password.

     

     

    Thanks for any help everyone! I know this is a big list and such, but i don't know how to do such stuff, due to not even being done with my first semester of Visual Basic. :P

    Thanks again,

    ProgramMonkey

     

    BTW, ya'll don't have to answer it all at once, lol :P Don't want to fry people's brains.

    Saturday, November 19, 2011 8:28 AM

Answers

  • On the next posts, please describe Your problem more compactly.

    Answer 1:

    • In Visual Studio, Project menu > 'ConsoleApplication1' Properties > Settings
      Name: "FirstRun",   Type: "String",    Score: "User",     Value: "False"

      Type:
      If My.Settings.FirstRun = "False" Then
      '''' Make user sign in My.Settings.FirstRun = "True" My.Settings.Save() End If

     

    Answer 2:

    • Write data to a text file, or do the same thing as above, create fields for the entries in the Settings tab. You can access the settings via:
      My.Settings.<Settings Name>

     

    Answer 3:

    • You can use Console.WriteLine("""" & usernam & """") for every field (except password), it would show: "Jacob" "Black"
      PS. The four "  ( """") mean: beginning of string, a " symbol (presented via two " symbols), end of string

     

    Answer 4:

    • Just modify the third arrays value userInfo[2] = "new Password"

    • Proposed as answer by Jacob Brown Saturday, November 19, 2011 5:02 PM
    • Edited by Jacob Brown Saturday, November 19, 2011 5:02 PM
    • Marked as answer by ProgramMonkey Saturday, November 19, 2011 10:53 PM
    Saturday, November 19, 2011 5:01 PM

All replies

  • On the next posts, please describe Your problem more compactly.

    Answer 1:

    • In Visual Studio, Project menu > 'ConsoleApplication1' Properties > Settings
      Name: "FirstRun",   Type: "String",    Score: "User",     Value: "False"

      Type:
      If My.Settings.FirstRun = "False" Then
      '''' Make user sign in My.Settings.FirstRun = "True" My.Settings.Save() End If

     

    Answer 2:

    • Write data to a text file, or do the same thing as above, create fields for the entries in the Settings tab. You can access the settings via:
      My.Settings.<Settings Name>

     

    Answer 3:

    • You can use Console.WriteLine("""" & usernam & """") for every field (except password), it would show: "Jacob" "Black"
      PS. The four "  ( """") mean: beginning of string, a " symbol (presented via two " symbols), end of string

     

    Answer 4:

    • Just modify the third arrays value userInfo[2] = "new Password"

    • Proposed as answer by Jacob Brown Saturday, November 19, 2011 5:02 PM
    • Edited by Jacob Brown Saturday, November 19, 2011 5:02 PM
    • Marked as answer by ProgramMonkey Saturday, November 19, 2011 10:53 PM
    Saturday, November 19, 2011 5:01 PM
  • Thanks man!!!! The My.Settings.<Settings Name> worked perfectly! It saved my data and it's working great! I set up the change password, using the My.Settings set up and everything is smooth. I'm currently working on a way to store more  than one user on the program, but please don't give anything yet on it. When the time comes, i may ask for guidance.

     

    Thanks again, Jacob!!!!!!!!!

    Saturday, November 19, 2011 10:53 PM