Results 1 to 7 of 7

Thread: Append to end of TExt Control

  1. #1
    Join Date
    Feb 2003

    Append to end of TExt Control

    How do I consistently add copy text from one TXTextControl to another, always appending to the END of the one being transferred to? I can't seem to figure this out.

    All responses appreciated.

    Attempted code snippet shown below.


    frmMain.TXTextControlOutput.SelLength = 0
    frmMain.TXTextControlOutput.SelStart = Len(frmMain.TXTextControlOutput.Text)
    frmMain.TXTextControlOutput.RTFSelText = frmMain.TXTextControlIn.RTFSelText

    ' The code above does not work consistently. Line feeds are missing sometimes.
    Last edited by bitpusher1010; February 27, 2003 at 15:57:50.

  2. #2
    Heiner Suhr Guest
    There is a problem with using RTFSelText this way. It is not really a bug, but still doesn't always work as expected. In brief, the problem is that the last paragraph's attributes (indents, tabs, ..) will only be copied if the pargraph ends with a line feed.

    These problems do not occur if you use the newer SaveToMemory and LoadFromMemory methods instead.

    Heiner Suhr, TX Text Control

  3. #3
    Join Date
    Feb 2003
    Ok, I switch to using the SaveToMemory and LoadFromMemory(). I get the same results, effectively the lines are not properly pasted into the target TXControl. Please see the code below, what I'm trying to do is take the contents of one TX control and copy them into the target TX control, one line at a time, skipping empty lines.

    ' Remove empty lines
    sText = frmMain.TXTextControl1.Text
    lTextLen = Len(sText) + 2 ' Had to add 2 here for potential extra CR LF not detected by Len()

    lLastPosition = 0 ' Yes indeed, the first character is at 0
    frmMain.TXTextControlOutput.Text = "" ' Clear out
    For ii = 1 To lTextLen
    lPos = InStr(ii, sText, vbLf)
    If (lPos > 0) Then ' we've got a paragraph!
    Dim data() As Byte
    ' Select the text
    frmMain.TXTextControl1.SelStart = lLastPosition
    frmMain.TXTextControl1.SelLength = (lPos - lLastPosition)
    ' Check for empty line
    sSel = frmMain.TXTextControl1.SelText
    sSel = Replace(sSel, " ", "")
    sSel = Replace(sSel, vbLf, "")
    lLen = Len(sSel)
    ' Add to target if not empty line
    If (lLen <> 0) Then
    data = frmMain.TXTextControl1.SaveToMemory(, True)
    frmMain.TXTextControlOutput.SelLength = 0
    frmMain.TXTextControlOutput.SelStart = Len(frmMain.TXTextControlOutput.Text)
    Call frmMain.TXTextControlOutput.LoadFromMemory(data, , True)
    End If
    lLastPosition = lPos
    ii = lPos
    Else ' check to see if there is any data left in string that has no LF
    End If
    Next ii

    When I have the original look like this:




    This program really is quite awesome excellent. I mean it really is. Sometimes it is just great. Got to keep on working on it. Make it better. I will get more customers!"

    The Output ends up looking like this:

    BBCCDDEEFFIThis program really is quite awesome excellent. I mean it really is. Sometimes it is just great. Got to keep on working on it. Make it better. I will get more customers!

    A whole bunch of Line feeds appear at the end of the output document.

    Thanks for your assistance.

  4. #4
    Join Date
    Feb 2003

    TXControl.SelStart But?????

    There seems to be a bug with the following line:

    frmMain.TXTextControlOutput.SelStart = Len(frmMain.TXTextControlOutput.Text)

    I'm attempting to append to the end of the text within a TX Control. However, the above line initiallly works ok, but then begins to fail after a few iterations of a loop. The Len() routine is working properly getting larger numbers 50+ however, after stepping over the assignment, the SelStart value is much less (i.e. 13 instead of 50).

    Am I doing something wrong, or is this a bug?

  5. #5
    Meik Dankleff Guest
    May I direct your attention to the following article? I think it pretty much covers what you are trying to do:

  6. #6
    Join Date
    Jan 2003
    Another possible approach is to simplify things. Why not just take the entire contents, replace all Chr(10) & chr(10) with a single chr(10) and insert the whole thing in one fell swoop? (Wonder what 'fell' actually means in that idiom?)

    (Might need to make 2 passes with the replace, but certainly seems more efficient)

  7. #7
    Join Date
    Feb 2003
    What I'm really trying to do is to copy the contents of one text control into another, removing all 'empty lines' while retaining the rich text formatting. 'Empty lines' include lines with only a line feed, and lines with nothing but spaces and line feeds. So a simple Replace() won't work here.

    Thanks for the suggestion however.

Similar Threads

  1. How to limit the pages in TX Text Control
    By Unregistered in forum TX Text Control ActiveX
    Replies: 1
    Last Post: July 6, 2005, 17:26:29
  2. TX Text Control .NET v11.00 released
    By Webmaster in forum TX Text Control .NET for Windows Forms
    Replies: 6
    Last Post: April 29, 2004, 10:32:56
  3. Replies: 2
    Last Post: August 13, 2003, 17:46:34
  4. New to TX Text Control? Read This!
    By Webmaster in forum TX Text Control ActiveX
    Replies: 0
    Last Post: March 21, 2003, 17:04:14
  5. NOT allowing images to be pasted into TX Text Control
    By gboesel in forum TX Text Control ActiveX
    Replies: 3
    Last Post: March 14, 2003, 18:16:31


Posting Permissions

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