Is this a bug in Rich Textbox control or my OS?
Posted on 2003-10-27
I've got a serious problem that I need to fix. I apparently have a "bug" in my operating system or VB runtime files, which causes the Richtextbox RTF control to insert extra Carriage Returns (hex OD) in front of certain CR/LF occurrences.
The "notepad replacement" app that I developed in VB6 is not useful as long as this bug is present on this computer.
I'm running windows 2000, and have developed a small test application to duplicate this. The bug does NOT happen when I copy the executable to any other systems running winXP, win98, or win2k. Only happens on my one particular win2k system.
It exhibits the same faulty behavior whether compiled in VB5 or VB6. The bug also happens when I migrated this project into Visual studio.NET 2002 with the migration wizard. However when creating a new VB.NET project with the RTF control, the bug does NOT happen.
My test app duplicates this with a particular file, which is about 6K in size, and has been verified with a hex editor to contain no consecutive Carriage Returns (all Carriage return characters are followed by linefeed characters). Each time the F3 button is pushed, my app advances the memory cursor and displays the ascii value via the following function
Asc(Mid(RichTextBox1.Text, RichTextBox1.SelStart, 1))
At the end of my particular file is a CR/LF, and my program displays decimal values 13,13,10 which is CR/CR/LF. (extra carriage return added)
The reason I have to use a special file to duplicate this is because this bug apparently only happens when a CR/LF combination happens at a particular boundary in memory. If I insert or remove any characters before the location of the CR/LF bug, then the bug does NOT happen and I see a single CR/LF.
The bug also happens when I boot into safe mode (with no loaded drivers I know of), and with different versions of the richtx32.ocx control. To give an idea of infrequently the bug occurs, a large text file of about 150Kb with about 4000 lines (CR/LFs) results in only THREE inserted carriage returns, so apparently the vast majority of those carriage returns do not fall on the appropriate memory boundaries to make the bug happen. However it has completely killed the usefulness of the app for its intended purpose.
but I have removed VB6 and loaded VB5, but the bug still happens as before. This is a corporate work computer that runs many many apps with no problem, so reloading the OS is not an option at this point.
What else can I check to fix this?