Thread: save text to file??

  1. #1
    Registered User
    Join Date
    Mar 2002

    save text to file??

    C+Builder problems.
    How do I write some text in a label, where after pushing Enter it will be saved into a file.

    And the Question goes the other way around.
    How can I read a file into a label.

    tx for your help

  2. #2

    Thumbs up Try this!

    You should use an edit box for any text that will change, if you dont want the text hand edited set it to read only. When using an Edit box look under methods at something like LoadFromFile or SaveToFile. Im not at home with my C++ Builder at the moment and I can't remember exactly what they are called but you'll know it when you find it.

    If you really want to use a label, which I don't recommend for text that will change try using fstream to send the data to a file stream.

    Why don't I recommend labels for text that will change at runtime???

    Think about it, If you write in text at runtime that is longer than the space you've allowed for the text label it might scroll of the window or over/under other components. If you use an edit box this won't happen as the box will just scroll. Generally text boxes are used for static text and edit boxes for dynamic. There are occasions when using a text box is the best way to go, but you should avoid it if you can.

  3. #3
    Registered User
    Join Date
    May 2002
    You could alternatively try the File I/O functions provided by MFC
    tudehopet uses Borland Compiler 5.5
    and Visual C++ 6.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM