Private currentposition As Integer = 0
Private rtb_Selectionlen As Integer = 0
Private rtb As RichTextBox
'首行缩进
Public Sub SetFirstLineIndent()
'获取当前插入运镇陆点的位置
currentposition = rtb.GetFirstCharIndexOfCurrentLine
rtb_Selectionlen = rtb.SelectionLength
'找出全部换行符的位置并存入数组中
Call FindFirstCharOfParagraph()
'找到插入点所在段落的首字符位置
FindPositonofFirstChar()
'进行首行缩进
InsertIndent(firstlineindentvalue)
End Sub
'找出全部段落首行首字符的位置并存入数组中
Public Sub FindFirstCharOfParagraph()
Dim indexofposition As Integer = 0
Dim startposition As Integer = 0
Dim indexofarray As Integer = 1 '数组的索引从1开始,因为0已经被缺省
position(0) = 0 '将旁顷第一段定为0
Do
indexofposition = rtb.Find(Chr(13), startposition, RichTextBoxFinds.None)
If indexofposition >旅液= 0 Then
position(indexofarray) = indexofposition + 1 '当前换行符的位置加1就等于下一段的首字符位置
startposition = indexofposition + 1
indexofarray += 1
Else
'MsgBox("未找到!")
End If
Loop While indexofposition >= 0
End Sub
'获取当前字符所在行的首字符位置
Public Function FindPositionOfCurrentLine() As Integer
currentposition = rtb.GetFirstCharIndexOfCurrentLine
rtb_Selectionlen = rtb.SelectionLength
Return currentposition
End Function
在keydown过程写代码如果keycode=13(回车的话)
发送(SP)(TAB)(SP)给文本框,
然后再回车
=============
看你喜欢了,vb的空格可以控制
space(10),就是10个空格了
tab写法是vbTab,回车换行时森余vbCrLf
我开始没有明白你sp的意思,如果是空格加tab,简单,这帆春肆态轿样
'如果输入回车,自动添加4个空格,一个tab,4个空格到下一行开始
if keycode=13 then
text1.text= text1.text &vbcrlf &space(4) &vbtab &space(4)
end if
如果你不要那么多空格,或者多几个/少几个tab,自己改啦,
知道怎么改就行了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)