none
How to add commas, spaces after each textbox in Visual Basic 2010 so that in my orderdata.txt I have data orgonized?

    Question

  • ' save order data
        Dim path As String = "C:\Users\Moisey\Documents\Visual Studio 2010\Projects\Moonbucks Coffee Solution\Moonbucks Coffee\bin\orderdata.txt"
    
        ' This text is added only once to the file.
        If File.Exists(path) = False Then
    
          ' Create a file to write to.
          Dim createText As String = "Hello and Welcome" + Environment.NewLine
          File.WriteAllText(path, createText)
        End If
    
        ' This text is always added, making the file longer over time
        ' if it is not deleted.
        Dim appendText As String = (nameTxtBox.Text) + (addressTxtBox.Text) + (cityTxtBox.Text) + (stateTxtBox.Text) + Environment.NewLine
        File.AppendAllText(path, appendText)
    
        ' Open the file to read from.
        Dim readText As String = File.ReadAllText(path)
        Console.WriteLine(readText)
     

     

    I have ^ this in my code and I want to have a comma and a space after each string so like this " Michael Jordan, 888 S Manderine Road, Airborne, CA 97842," but I keep getting this "Michael Jordan888 S Manderine RoadAirborneCA97842". I'm completely new to this but I need help on this, its driving me nuts! I want to have the right format of info organized so that when i open my file it says exactly the same as the first example that i want!

    Tuesday, February 01, 2011 5:57 AM

Answers

  • Try this:

     

      Dim appendText As String = (nameTxtBox.Text) + ", " + (addressTxtBox.Text) + ", " + (cityTxtBox.Text) + ", " + (stateTxtBox.Text) + Environment.NewLine
      File.AppendAllText(path, appendText)
    

    • Marked as answer by magasiev13 Tuesday, February 01, 2011 6:32 AM
    Tuesday, February 01, 2011 6:14 AM

All replies

  • Try this:

     

      Dim appendText As String = (nameTxtBox.Text) + ", " + (addressTxtBox.Text) + ", " + (cityTxtBox.Text) + ", " + (stateTxtBox.Text) + Environment.NewLine
      File.AppendAllText(path, appendText)
    

    • Marked as answer by magasiev13 Tuesday, February 01, 2011 6:32 AM
    Tuesday, February 01, 2011 6:14 AM
  • Try this:

     

     

     Dim appendText As String = (nameTxtBox.Text) + ", " + (addressTxtBox.Text) + ", " + (cityTxtBox.Text) + ", " + (stateTxtBox.Text) + Environment.NewLine
     File.AppendAllText(path, appendText)
    
    

    Thank You

    I totally didn't think of that!

    Tuesday, February 01, 2011 6:32 AM