Results 1 to 4 of 4

Thread: Loading and Saving text..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    98

    Loading and Saving text..

    I have asked this before.. and I had it in a text file.. but it was like 3 months ago and I reformatted, but anyways... How would I load and save text from a common dialog named cd ... the text box is text 1 and it is set to multiline.. I am making sorta a text editor... but its for quake and opens and edits .cfg files.. can anyone help ?
    Visual basic 6.0 Enterprise Edition
    [email protected]

  2. #2
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    A easy way to load the file would be as follows in this case i used a richtextbox1 instead of a textbox.

    cd.Filter = "CFG Files (*.CFG)|*.CFG|All Files (*.*)|*.*"
    cd.ShowOpen
    RichTextBox1.LoadFile (CommonDialog1.FileName)

    and to save:

    cd.Filter = "CFG Files (*.CFG)|*.CFG|All Files (*.*)|*.*"
    cd.ShowSave
    RichTextBox1.SaveFile (CommonDialog1.FileName)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Posts
    98
    I cant use richtextbox, it says that it doesnt have a liscense..
    Visual basic 6.0 Enterprise Edition
    [email protected]

  4. #4
    Member bizzyVB's Avatar
    Join Date
    Jun 2001
    Location
    Florida
    Posts
    38
    okay so your not using richy... then heres the code for a regular text box...

    'to load the text...
    commondialog1.filter = "CFG Files (*.cfg) | *.cfg"
    commondialog1.dialogtitle = "open a cfg file.."
    commondialog1.showopen

    open commondialog1.filename for input as #1
    text1.text = Input(LOF(1),1)
    close #1

    'to save the text
    commondialog1.filter = "CFG Files (*.cfg) | *.cfg"
    commondialog1.dialogtitle = "save a cfg file.."
    commondialog1.showsave

    open commondialog1.filename for output as #1
    print #1, text1.text
    close #1

    there you go!
    my first post

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