Line Spacing in RichTextBox
You can use a RichTextBox and set custom LineSpacing.
See the code below.
(Note: This code most likely will NOT work on Windos98/Me)
vb Code:
' add a RichTextBox, a Textbox and a CommandButton in a form.
' Type the line-spacing you want (in twips) in the textbox
' and hit the command button
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal HWND As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_USER = &H400
Const EM_GETPARAFORMAT As Long = (WM_USER + 61)
Const EM_SETPARAFORMAT = WM_USER + 71
Const PFM_LINESPACING As Long = &H100
Const MAX_TAB_STOPS = 32
Private Type PARAFORMAT2
cbSize As Long
dwMask As Long
wNumbering As Integer
wEffects As Integer
dxStartIndent As Long
dxRightIndent As Long
dxOffset As Long
wAlignment As Integer
cTabCount As Integer
rgxTabs(MAX_TAB_STOPS - 1) As Long
dySpaceBefore As Long
dySpaceAfter As Long
dyLineSpacing As Long
sStyle As Integer
bLineSpacingRule As Byte
bOutlineLevel As Byte
wShadingWeight As Integer
wShadingStyle As Integer
wNumberingStart As Integer
wNumberingStyle As Integer
wNumberingTab As Integer
wBorderSpace As Integer
wBorderWidth As Integer
wBorders As Integer
End Type
Private Function SetLineSpacing(lHwnd As Long, LineSpacingInTwips As Long)
Dim pf2 As PARAFORMAT2
Dim lR As Long
pf2.cbSize = Len(pf2)
SendMessage lHwnd, EM_GETPARAFORMAT, 0&, pf2
'
pf2.dwMask = PFM_LINESPACING
pf2.bLineSpacingRule = 4
pf2.dyLineSpacing = LineSpacingInTwips
pf2.cbSize = Len(pf2)
SendMessage lHwnd, EM_SETPARAFORMAT, 0, pf2
End Function
Private Sub Command1_Click()
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.Text)
SetLineSpacing RichTextBox1.HWND, Val(Text1.Text)
RichTextBox1.SelLength = 0
End Sub
Private Sub Form_Load()
Text1.Text = 170 'this value looks good in my comp
End Sub