[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

Richtextbox ocx bug with plain text insert?

I have encountered a strange problem with RichTextbox OCX.

I'm using it as a base for a source editor, in order to colorize tokens etc. I'm using VB6.

With certains text sources(no rtf, just plain text) inserting a char in editor and then call
DocLen = len(RichTextBox.text)
give me a DocLen value increased of 3 units (instead of 1 that I espect  as i've inserted only one char) and I found that somewhere after that line it has added a vbcrlf char (this can be 10, or 20 or more lines after insertion point)

This strange behaviour make my multi-level undo class to fail since it thinks that I've replaced some text and not just inserted one (since i've digited only one char that is not vbcrlf and docLen is increased by 3)

Thanks for any help
0
fabiobond
Asked:
fabiobond
  • 3
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
How are you inserting the text into the RichTextbox?

Idle_Mind
0
 
cnfeiCommented:
Try to initialize the RichTextBox.text in form load to make sure there is nothing in the rich text box.


Private Sub Form_Load()
    RichTextBox.Text = ""
End Sub
0
 
fabiobondAuthor Commented:
Please downloand this demo project to realize what the bug is.

If you load the testdoc1.bb all works fine, but if you load the testlong.bb file you will find that during RichTextBox Change Event len(RTB.Text) returns strange values!

Download test project here:
http://www.beggi.it/roccia/downloads/RTBBug.zip
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
cnfeiCommented:
I have downloaded your program and try to run by using both of the files.

I found that the result is normal.
Both of them return correct length when i change the RTB value.

The testdoc1.bb got 573 characters
The testlong.bb got 233065 characters
0
 
fabiobondAuthor Commented:
On my Pc I get

575 characters for testdoc1.bb (this should be correct since from file properties tab i read it's size is 575 bytes)
233068 characters for testlong.bb

in testlong.bb, the onchange event is called every time i insert a character but the value of txtDocLen sometimes remain unchanged between keystrokes and sometimes increases of more than a unit.

At this point I think there is some problem with my installation


What should I try? What to reinstall? I've WinXP Pro (no SP1) and OfficeXP Pro.
0
 
fabiobondAuthor Commented:
I've installed XP service pack 1 and now the control works as it should be

Thanks cnfei for your time
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now