Solved

Richtextbox ocx bug with plain text insert?

Posted on 2004-04-19
6
443 Views
Last Modified: 2013-12-26
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
Comment
Question by:fabiobond
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 10862586
How are you inserting the text into the RichTextbox?

Idle_Mind
0
 

Expert Comment

by:cnfei
ID: 10865019
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
 

Author Comment

by:fabiobond
ID: 10866776
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
Technology Partners: 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!

 

Accepted Solution

by:
cnfei earned 500 total points
ID: 10867163
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
 

Author Comment

by:fabiobond
ID: 10867555
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
 

Author Comment

by:fabiobond
ID: 10868189
I've installed XP service pack 1 and now the control works as it should be

Thanks cnfei for your time
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question