📄 form1.frm
字号:
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form Form1
Caption = "RichTextBox 控件中实现上、下标形式"
ClientHeight = 2145
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2145
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin RichTextLib.RichTextBox RichTextBox1
Height = 735
Left = 1200
TabIndex = 0
Top = 360
Width = 1575
_ExtentX = 2778
_ExtentY = 1296
_Version = 393217
TextRTF = $"Form1.frx":0000
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
RichTextBox1.Font.Name = "Times New Roman"
RichTextBox1.Font.Size = 10
RichTextBox1.Text = "H2SO4"
'向下移动两个象素.
OffsetRichText RichTextBox1, 1, 1, 2
OffsetRichText RichTextBox1, 4, 1, -2
End Sub
Private Sub OffsetRichText(rText As RichTextBox, start As Integer, length As Integer, _
offset As Integer)
'start作为上、下标字符的起始位置;length指上下标字符的长度。
'offset指上标还是下标,大于0上标;小于0下标。
rText.SelStart = start
rText.SelLength = length
rText.SelFontSize = rText.Font.Size - Abs(offset)
rText.SelCharOffset = ScaleY(offset, vbPoints, vbTwips)
rText.SelStart = 0
rText.SelLength = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -