VB EE 2005 Reading/writing text box content to a text file?

Hi coders

How do you capture the content of a text box filled in by the user to a text file, appending new content and opening that file into the text box each time the application opens and showing the last entry first

Thanks in advance...newtWales




Answer this question

VB EE 2005 Reading/writing text box content to a text file?

  • Raj Amb

    Hi CWIZO

    I agree, many solutions are "out there" and I always look [and have been successful] first before asking for help. The trouble with many tutorials is they always seem to leave out a key bit of information: either it's forgotten or they simply assume you know it already. The trouble with being a newby is that you don't know what you don't know: for example, what is there in the phrase "System.IO namespace" that tells a novice this is what they need to write text to a file



  • MadhuBabu

    Many thanks for the http link; I will try out your solution.

  • JohnMcKenzie

    My.Computer.Filesystem.ReadAllText and My.Computer.Filesystem.WriteAllText will read and write a string to a file.

    Very simple functions to use.

    So these functions above are just writing what is in the textbox to a file and reading it back.

    Perhaps I'm not quite getting what you want when you are talking about entries and a single text box. As the text that is being shown in the textbox is just text from the file.

    If say you are wanting to store multiple records into an textfile and you want to reverse the order when you retrieve it... ie Display Records in order 5,4,3,2,1 but save it in the file in order 1,2,3,4,5 then you will need to write some form of parser and have some form of delimiter to distinguish when one entry finishes and the next begins.

    The you may take look at something like My.COmputer.Filesystem.TextFileParser

    http://msdn2.microsoft.com/library/x710fk43(en-us,vs.80).aspx

    to read the records in and then re-order them to display and vice versa

    But I think this may be more complicated and possibly better handled by simply storing in the same order as you displaying - and hence no need to reorder the entries.


  • Tom Nguyen

    You have everything you need in the System.IO namespace. And there are many tutorials avalible on this subject. All you have to do is search for them ;)


  • VB EE 2005 Reading/writing text box content to a text file?