technofantasy

博客园 首页 新随笔 联系 订阅 管理
visual basic code:
Dim iPos As Long
Dim strInsert As String
Dim strRTF As String
Dim lStart As Long

'assumes that strInsert contains the RTF code that you want to insert
'
and that the current cursor position is where you want it selected
    With RichTextBox1
      
'mark the current insertion point with special characters
        .SelText = Chr(&H9D) & Chr(&H81)
      
'get the rtf text into our variable
        strRTF = .TextRTF
      
'insert our text at the insertion point
        strRTF = Replace(.TextRTF, "\'9d", strInsert)
        .TextRTF 
= strRTF
      
'now find the end of the insertion
        lStart = .Find(Chr(&H81))
      
'get rid of the other character
        strRTF = Replace(.TextRTF, "\'81""")
        .TextRTF 
= strRTF
      
'position the cursor after the insertion
        .SelStart = lStart
   
End With
posted on 2006-09-06 17:06  陈锐  阅读(943)  评论(0编辑  收藏  举报