InputString produces multiple text strings

  • Hi, I have a problem with the following:

    In VB.Net 2005 I have a WinForms program which uses SQL Server at the back end. Data which has line breaks in it which is saved into the database via a memo control on a form is not being render correctly.

    The code being used is as follows:
    textcursor.FindText("$WorkRequired", True, False, True, True, found)
    If found Then
    MessageBox.Show(job.WorkRequired.ToString)
    textcursor.SelectText(textcursor.CPPosition, textcursor.CPPosition + 13)
    textcursor.InputString(job.WorkRequired.ToString, intNames)
    End If

    The messagebox (which is included only for confirmation purposes) shows the correct text which I have also confirmed by looking at the database table.

    When the string is entered into the Text Dynamic editing window lines after the carriage returns are repeated. An example is shown below.

    Line 1

    Line 2

    would be rendered as:

    Line 1

    Line 2

    Line 2

    Note that I get the same behaviour when I use marked fields.

    Any suggestions?

    Thanks

  • Upon further investigation I have found that if I do a Replace on the vbCrLf with a Chr(10) then it renders correctly i.e.

    textcursor.InputString(job.WorkRequired.ToString.Replace(vbCrLf, Chr(10)), intNames)

    Why is this so?

    • Offizieller Beitrag

    Hi,

    Char(10) is handled a s a new line character, it does not break up a aparagraph.

    Char(13) is the new paragraph character.

    (BTW: Char(12) will create a new page and Char(127) will delete the char right to cursor)

    InputString workls like standard typing, so CRLN are interpreted as individual key strokes with the respecitve function.

    You can use Memo.LoadFromString or Memo.LoadFromVar to insert a larger text at cursor position using the ANSI or other filtes (RTF, HTML)

    Regards,

    Julian Ziersch