标题: RichTextBox技巧之插入上标和下标(转载)
- 陈锐 2006-09-06 17:10 阅读:249
- 评论:0 | 添加评论
[图片][图片]Public Sub SetSubScript()Sub SetSubScript(RTB As RichTextBox)
[图片]Dim iPos As Long
[图片]Dim strRTF As String
[图片]        With RTB
[图片]        If .SelCharOffset >= 0 Then
[图片]        'subscript the current selection
[图片]            iPos = .SelStart
[图片]            .SelText = Chr(&H9D) & .SelText & Chr(&H81)
[图片]            strRTF = Replace(.TextRTF, "\'9d", "\sub\dn2 ")
[图片]            .TextRTF = Replace(strRTF, "\'81", "\nosupersub\up0 ")
[图片]            .SelStart = iPos
[图片]        Else 'turn off subscripting
[图片]            .SelText = Chr(&H9D) & .SelText
[图片]            strRTF = .TextRTF
[图片]            .TextRTF = Replace(strRTF, "\'9d", "\nosupersub\up0 ", , 1)
[图片]        End If
[图片]        End With
[图片]End Sub
[图片]
[图片][图片]Public Sub SetSuperScript()Sub SetSuperScript(RTB As RichTextBox)
[图片]'add tags \super\up1 and \nosupersub\up0
[图片]Dim iPos As Long
[图片]Dim strRTF As String
[图片]      With RTB
[图片]        iPos = .SelStart
[图片]        If RTB.SelCharOffset <= 0 Then
[图片]        'superscript the current selection
[图片]            .SelText = Chr(&H9D) & .SelText & Chr(&H80)
[图片]            strRTF = Replace(.TextRTF, "\'9d", "\super\up2 ")
[图片]            .TextRTF = Replace(strRTF, "\'81", "\nosupersub\up0 ")
[图片]        Else 'turn off
[图片]            .SelText = Chr(&H9D) & .SelText
[图片]            strRTF = .TextRTF
[图片]            .TextRTF = Replace(strRTF, "\'9d", "\nosupersub\up0 ", , 1)
[图片]        End If
[图片]        .SelStart = iPos
[图片]       End With
[图片]End Sub

添加评论
返回顶部 | 返回首页