Results 1 to 2 of 2

Thread: [RESOLVED] WriteAllText: append with a space, multiple variables

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Location
    Australia
    Posts
    130

    Resolved [RESOLVED] WriteAllText: append with a space, multiple variables

    Hi all.

    I am using the below code to write to a file. Each time this code is used, it appends to the file, with no space between the old and new entry.

    1. How can I append with a space between the two entries?

    2. What about writing multiple variables? If I have two variables, NewEvent1 & NewEvent2, how can I write both to the file, with a comma between them?

    EDIT: Forgot to mention that I want to separate with a comma because I want to read the variables back from the file. So the comma is a delimiter.

    Thanks in advance.

    Code:
    My.Computer.FileSystem.WriteAllText("events.txt", NewEvent, True)
    Last edited by vbforever23; May 20th, 2013 at 08:20 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: WriteAllText: append with a space, multiple variables

    You're not really thinking about this logically. The code you're using appends the contents of a String to a file. Whatever you want to append to the file, you put in that String. If you want to append a space followed by some text then you put a space followed by some text in a String. If you want to append some text followed by a comma followed by some more text then you put some text followed by a comma followed by some more text into a String. How do you usually join multiple Strings together into one? That's exactly what you do here.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width