Solved

Richtextbox ocx bug with plain text insert?

Posted on 2004-04-19
6
444 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 86

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

732 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