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
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
End Sub
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.