VB Migration Partner

KNOWLEDGE BASE - Forms and controls


Previous | Index | Next 

[INFO] Minor differences between VB6 and VB.NET RichTextBox controls

VB Migration Partner’s support library hides most of the differences between the VB6 and the .NET versions of the RichTextBox control, but not all of them. In most cases the remaining differences should have no impact on migrated programs. Here’s their complete list:

  1. The font of the text assigned to the Rtf property at design time – that is, in VB6 Property window - might be different in the converted VB.NET program. This change is necessary because .NET controls don’t accept System fonts such as MS Sans Serif or Courier.
  2. The VB6 control stores newline characters as CR-LF pairs (ASCII 13 + ASCII 10), whereas the VB.NET control stores them as individual LF characters (ASCII 10). You should keep this detail into account if your code counts the number of lines by searching newline sequences.
  3. The VB6 control ignores invalid font assignments, unlike the VB.NET control. For example, the following code works correctly in VB6:
        Me.RichTextBox1.SelItalic = False
        Me.RichTextBox1.SelBold = False
        Me.RichTextBox1.SelrFontName = "Brush Script MT"
    whereas under VB.NET the same code throws an ArgumentException error, whose message reads “Font ‘Brush Script MT’ doesn’t support style ‘Regular’.
  4. Reading back a value assigned to the SelHanging, SelIndent, and SelTabs properties might return a value different from the value assigned previously. The reason for this behavior is that these properties take or return values in twips – more precisely, in the container’s ScaleMode – whereas the .NET control internally stores these values in pixels. When you assign a value to one of these properties the value is internally converted to pixel and then converted back to twips when the property is read back. Pixels values are stored internally as integers, therefore the double conversion might bring to a loss of precision.
  5. In the VB6 control, the SelTabCount property is – to an extent – independent of the current selection. More precisely, this property returns Null if the selection spans paragraphs with different tab settings. However, if you then assign any value to the SetTabs(n) property, the SelTabCount property returns the highest of the SelTabCount values for all the paragraphs in the selection, and you can query the SelTabs(n) property for each value of N included between 0 and SelTabCount-1, even if you never actually assigned the N-th tab for a given paragraph.
    Under VB.NET, the SelTabCount property behaves differently. If the current selection includes includes two or more paragraphs with different tab settings, this property returns 0 (zero). If you then assign a value to the SetTabs(n) property an exception occurs.
  6. When the end user selects a piece of text with the mouse, when he or she releases the mouse button the VB6 control fires the following events: MouseUp, Click, SelChange. In the same circumstances, the VB.NET control fires the same events but in a different order: Click, SelChange, MouseUp.
  7. If the OLEDragMode property is set to 2-Automatic, the VB6 RichTextBox control has an inconsistent behavior when a file is dropped on it, for example at the end of a drag-and-drop operation initiated from Windows Explorer: depending on the nature of the file, the RichTextBox control either displays the file contents or the file icon and name. The VB.NET version of the RichTextBox always displays the file contents.
Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers