technofantasy

博客园 首页 新随笔 联系 订阅 管理
  22 Posts :: 16 Stories :: 62 Comments :: 1 Trackbacks
Public 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(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
posted on 2006-09-06 17:10 陈锐 阅读(222) 评论(0)  编辑 收藏 所属分类: RichTextBox技巧

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
 
另存  打印