Results 1 to 5 of 5

Thread: saving txt in rich text boxes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Lowestoft
    Posts
    91
    How do you save plain text in a rich text box?
    Mag-Net's Home
    Visual Studio 6-Enterprise - SP4
    ICQ: 35519773
    Have Fun

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Is this what you want to do?

    Code:
    Option Explicit
      
    Private Sub Command1_Click()
     SavePlainText RichTextBox1, "c:\rawtext.txt"
     
    End Sub
    Private Sub SavePlainText(Rtb As RichTextBox, filename As String)
    Dim fnum As Byte
    fnum = FreeFile
    Open filename For Binary As fnum
    Put #fnum, , Rtb.Text
    Close fnum
    
    End Sub
    Mark
    -------------------

  3. #3
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    Mark,

    What does your signature mean? I converted it to dec, but I couldnt take anything valuable from doing that?

    You have me intrigued.

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    it is just the ascii values for "Mark Sreeves" in binary.

    for some reason the spacing goes all weird though.

    the digits should of-course be in groups of 8

    [Edited by Mark Sreeves on 07-18-2000 at 08:42 AM]
    Mark
    -------------------

  5. #5
    Guest

    Exclamation Use SaveFile

    A shorter method is to use the built in SaveFile method and pass rtfText as the flag.

    Code:
    'Pass rtfText as the flag. This tells the RichTextBox to save in plain text. 
    RichTextBox1.SaveFile "C:\MyFile.txt", rtfText

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