Solved

Richtextbox ocx bug with plain text insert?

Posted on 2004-04-19
6
440 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
  • 3
  • 2
6 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
How are you inserting the text into the RichTextbox?

Idle_Mind
0
 

Expert Comment

by:cnfei
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Accepted Solution

by:
cnfei earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
I've installed XP service pack 1 and now the control works as it should be

Thanks cnfei for your time
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now