How do i format text with double LineSpacing in richtextbox in vb.net ?

Dear Expert
I am working on a text editor in vb.net I am unable to get 1.5 or double LineSpacing in the richtext box.
I am attaching code (which works in VB6) but when used in vb.net, after necessary changes(code is being attached). it does not work.
Please point out the mistake.
The reason could be difference in Class of RichTextBox. VB6 uses Rich Text WndClass while VB2005 uses WindowsForms10.RichEdit20w.app.0.3ee13a2.
Kindly suggest a code which works in VB.net

rmajay
rmajayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rmajayAuthor Commented:
CODE IN CV6 ( WORKS OK)
Option Explicit

Private Const EM_GETPARAFORMAT = &H43D
Private Const EM_SETPARAFORMAT = &H447
Private Const PFM_LINESPACING = &H100&

Private Type PARAFORMAT2
   cbSize               As Long
   dwMask               As Long
   wNumbering           As Integer
   wReserved            As Integer
   dxStartIndent        As Long
   dxRightIndent        As Long
   dxOffset             As Long
   wAlignment           As Integer
   cTabCount            As Integer
   lTabstops(31)        As Long
   dySpaceBefore        As Long          ' Vertical spacing before para
   dySpaceAfter         As Long           ' Vertical spacing after para
   dyLineSpacing        As Long          ' Line spacing depending on Rule
   sStyle               As Integer              ' Style handle
   bLineSpacingRule     As Byte       ' Rule for line spacing
   bCRC                 As Byte                   ' Reserved for CRC for rapid searching
   wShadingWeight       As Integer      ' Shading in hundredths of a per cent
   wShadingStyle        As Integer       ' Nibble 0: style, 1: cfpat, 2: cbpat
   wNumberingStart      As Integer     ' Starting value for numbering
   wNumberingStyle      As Integer     ' Alignment, roman/arabic, (), ), .,     etc.
   wNumberingTab        As Integer       ' Space between 1st indent and 1st-line text
   wBorderSpace         As Integer        ' Space between border and text(twips)
   wBorderWidth         As Integer        ' Border pen width (twips)
   wBorders             As Integer            ' Byte 0: bits specify which borders; Nibble 2: border style; 3: color                                     index*/
End Type

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As PARAFORMAT2) As Long

Public Sub SelLineSpacing(ByVal hWnd As Long, ByVal SpacingRule As Byte, Optional ByVal LineSpacing As Long = 20)
   ' SpacingRule
   ' Type of line spacing. To use this member, set the PFM_SPACEAFTER flag in the dwMask member. This member can be one of the following values.
   ' 0 - Single spacing. The dyLineSpacing member is ignored.
   ' 1 - One-and-a-half spacing. The dyLineSpacing member is ignored.
   ' 2 - Double spacing. The dyLineSpacing member is ignored.
   ' 3 - The dyLineSpacing member specifies the spacingfrom one line to the next, in twips. However, if dyLineSpacing specifies a value that is less than single spacing, the control displays single-spaced text.
   ' 4 - The dyLineSpacing member specifies the spacing from one line to the next, in twips. The control uses the exact spacing specified, even if dyLineSpacing specifies a value that is less than single spacing.
   ' 5 - The value of dyLineSpacing / 20 is the spacing, in lines, from one line to the next. Thus, setting dyLineSpacing to 20 produces single-spaced text, 40 is double spaced, 60 is triple spaced, and so on.

   Dim Para             As PARAFORMAT2
   SendMessage hWnd, EM_GETPARAFORMAT, &H0, Para
   With Para
      .cbSize = Len(Para)
      .dwMask = PFM_LINESPACING
      .bLineSpacingRule = SpacingRule
      .dyLineSpacing = LineSpacing
   End With

   SendMessage hWnd, EM_SETPARAFORMAT, &H0, Para
End Sub

Private Sub Command1_Click()
   SelLineSpacing RichTextBox1.hWnd, 2, 0
End Sub

Private Sub Form_Load()
   Dim i                As Long
   Dim s                As String
   For i = 0 To 10
      s = s & "Item " & i & vbCrLf
   Next
   RichTextBox1.Text = s
End Sub




------------------------------
FOR CODE IN VB.NET (DOES NOT WORK)
SEE ATTACHED FILE LINESPACING.DOCX

linespacing.docx
0
Shahan AyyubSenior Software EngineerCommented:
For VB.net, use this property :

RichTextBox1.SelectionCharOffset = 10

you can vary the number '10'.Use this property where you want line spacing. Thats' it. :)

I found it from here:

http://www.vbforums.com/showthread.php?t=527619
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rmajayAuthor Commented:
Dear Shahan_Dev
YES it works.
This use of superscript property is very novel.
THANKS
rmajay
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.