VB下角标问题,请高手帮帮我,谢谢您
我之前问过,怎样才能搞出来下角标,有人告诉我用富文本框,然后给我这个例子
Private Sub Command1_Click() RichTextBox1.Font.Name = "Times New Roman" RichTextBox1.Font.Size = 20 RichTextBox1.Text = "X3Y4" OffsetRichText RichTextBox1, 3, 1, -6 End Sub Private Sub OffsetRichText(box As RichTextBox, start As Integer, length As Integer, offset As Integer) box.SelStart = start box.SelLength = length box.SelFontSize = box.Font.Size - Abs(offset) box.SelCharOffset = ScaleY(offset, vbPoints, vbTwips) box.SelStart = 0 box.SelLength = 0 End Sub
Option ExplicitPrivate Sub Command1_Click() RichTextBox1.Font.Name = "Times New Roman" '字体为Times New Roman RichTextBox1.Font.Size = 20 '字号为20 RichTextBox1.Text = "X3Y4" '字串为X3Y4 OffsetRichText RichTextBox1, 3, 1, -6 '调用 OffsetRichText过程生成下标,第一个参数为RichTextBox1,第二个参数表示从第四个字符开始,第三个参数表示只作用于1个字符,第四参数是下移量(缇) End Sub Private Sub OffsetRichText(box As RichTextBox, start As Integer, length As Integer, offset As Integer) box.SelStart = start '生成下标(选中)字符的开始位置 box.SelLength = length '生成下标(选中)字符的长度 box.SelFontSize = box.Font.Size - Abs(offset) '生成下(选中)字符的字号 box.SelCharOffset = ScaleY(offset, vbPoints, vbTwips) '把偏移量由磅转为缇 box.SelStart = 0 box.SelLength = 0 End Sub
[解决办法]