十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
太晚了,想不出什么好方法了。
创新互联是一家专注于网站设计、网站制作与策划设计,阳朔网站建设哪家好?创新互联做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:阳朔等地区。阳朔做网站价格咨询:13518219792
发上来看看吧。
首先建立一个TextBox,我这里名字为TextBox2
然后放一个groupbox,在里头放两个Checkbox,checkbox1为粗体,checkbox2为斜体。
代码:
Dim Bold As Boolean
Dim Italic As Boolean
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
Bold = True
If Italic Then
TextBox2.Font = New Font(TextBox2.Font, FontStyle.Bold Or FontStyle.Italic)
Else
TextBox2.Font = New Font(TextBox2.Font, FontStyle.Bold)
End If
Else
Bold = False
If Italic Then
TextBox2.Font = New Font(TextBox2.Font, FontStyle.Italic)
Else
TextBox2.Font = New Font(TextBox2.Font, 0)
End If
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked Then
Italic = True
If Bold Then
TextBox2.Font = New Font(TextBox2.Font, FontStyle.Italic Or FontStyle.Bold)
Else
TextBox2.Font = New Font(TextBox2.Font, FontStyle.Italic)
End If
Else
Italic = False
If Bold Then
TextBox2.Font = New Font(TextBox2.Font, FontStyle.Bold)
Else
TextBox2.Font = New Font(TextBox2.Font, 0)
End If
End If
End Sub
可以等等别人回答,看看有没有更好的方法。
Dim str As String = "", temp, n As Integer
Dim str1 As String = "12,45,2,9,41,31,66,83,2,1,-9,-91,-21"
Dim a() As String = Split(str1, ",")
For i = 1 To UBound(a) Step 1
a(i) = Val(a(i))
Next
temp = 0
n = 0
For i = 1 To UBound(a)
If a(i) temp Then
temp = a(i)
End If
If a(i) 0 Then
n = n + 1
End If
Next
str = str "正数的个数为 " n
str = str "最大元素的下标为 "
For i = 1 To UBound(a)
If a(i) = temp Then
str = str i " "
End If
Next
TextBox6.Text = str
改用富文本框(RichTextBox)控件或通过OLE的方式调用Word文档对象。还有一种方法就是用webbowser控件调用html文档来解决。总之,直接在文本框中是没办法输入的。如果是简单的符号,可以通过输入法的软键盘输入
用 RichTextBox控件,(菜单 工程》部件》选 microsoft Rich Txtbox...) Private Sub Form_Load()
RichTextBox1.Font.Name = "Times New Roman"
RichTextBox1.Font.Size = 10
RichTextBox1.Text = "H2SO4"
'注释: Move the numbers down 2 points.
OffsetRichText RichTextBox1, 2, 1, 2 ' 字串中第二个设为上标
OffsetRichText RichTextBox1, 5, 1, -2 ' 字串中第5个设为下标
End Sub'设置上下标
Private Sub OffsetRichText(box As RichTextBox, start As Integer, length As Integer, offset As Integer)
'注释:box指RichTextBox控件;start指作为上下标的
'注释:字符的起始位置;length指上下标字符的长度;
'注释:offset指上标还是下标,大于0上标;小于0下标。
box.SelStart = start - 1
box.SelLength = length
box.SelFontSize = box.Font.Size - Abs(offset)
box.SelCharOffset = ScaleY(offset, vbPoints, vbTwips)
box.SelStart = 0
box.SelLength = 0
End Sub