vb.net的RichTextbox调整行距

PrivateDeclareFunctionSendMessageLib"user32"Alias"SendMessageA"(ByValhwndAsLong,ByVal... Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As PARAFORMAT2) As Long
Const WM_USER = &H400
Const PFM_LINESPACING = &H100
Const MAX_TAB_STOPS = 32
Const EM_SETPARAFORMAT = WM_USER + 71

Structure PARAFORMAT2
Dim cbSize As Integer
Dim wPad1 As Integer
Dim dwMask As Long
Dim wNumbering As Integer
Dim wReserved As Integer
Dim dxStartIndent As Long
Dim dxRightIndent As Long
Dim dxOffset As Long
Dim wAlignment As Integer
Dim cTabCount As Integer
Dim lTabStops() As Long
Dim dySpaceBefore As Long
Dim dySpaceAfter As Long
Dim dyLineSpacing As Long
Dim sStyle As Integer
Dim bLineSpacingRule As Byte
Dim bCRC As Byte
Dim wShadingWeight As Integer
Dim wShadingStyle As Integer
Dim wNumberingStart As Integer
Dim wNumberingStyle As Integer
Dim wNumberingTab As Integer
Dim wBorderSpace As Integer
Dim wBorderWidth As Integer
Dim wBorders As Integer
End Structure
Public Sub RicHangJ(ByVal RicTxt As Object, ByVal Doi As Double) '设定Richtextbox行间距
Dim x As PARAFORMAT2
ReDim x.lTabStops(0 To MAX_TAB_STOPS - 1)
With RicTxt
.HideSelection = True
.SelectionStart = 0
.SelectionLength = Len(.Text)
x.cbSize = Len(x)
x.dwMask = PFM_LINESPACING
x.bLineSpacingRule = 5
x.dyLineSpacing = Doi * 20
Dim hn As Long = Val(.Handle.ToString)
Call SendMessage(hn, EM_SETPARAFORMAT, 0, x)
.SelectionStart = 0
.HideSelection = False '失去焦点时被选文字是否高亮显示F为是
End With
End Sub

上面这段代码是我从vb6.0中移动到vb.net,快我调试了许久也没有成功,请大侠帮帮忙看看,错在哪里,要写成怎样 先谢谢了
展开
 我来答
VB编程解放双手
2017-08-28 · 个人VB爱好者专注vb编程_时效软件
VB编程解放双手
采纳数:1204 获赞数:2391

向TA提问 私信TA
展开全部
把sendmessage改成postmessage试一试
更多追问追答
追问
还是显示 System.ArgumentException:“值不在预期的范围内。”
追答
调试运行的结果呢?停在哪行代码上了?
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式