VB6.0中如何使得一个字符串中的某一个字符选中高亮并使这个字符字体变大。
比如text1中有”adafasfa",先进行查询,找到"da",然后使"da"选中高亮,并变大。...
比如text1中有”adafasfa",先进行查询,找到"da",然后使"da"选中高亮,并变大。
展开
3个回答
展开全部
使用RichTextBox控件
Private Sub Command1_Click()
RichTextBox1.SelStart = 3 '#要高亮的起始字符数
RichTextBox1.SelLength = 5 '#要高亮的字符数
RichTextBox1.SelColor = vbRed '#颜色
RichTextBox1.SelFontSize = 20 '#字体
RichTextBox1.SelBold = True '#加粗
End Sub
Private Sub Command1_Click()
RichTextBox1.SelStart = 3 '#要高亮的起始字符数
RichTextBox1.SelLength = 5 '#要高亮的字符数
RichTextBox1.SelColor = vbRed '#颜色
RichTextBox1.SelFontSize = 20 '#字体
RichTextBox1.SelBold = True '#加粗
End Sub
展开全部
text1不支持。
似乎要使用一种ric...的控件,外观样子和text差不多。
似乎要使用一种ric...的控件,外观样子和text差不多。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
查找并选中找到的字符
'添加控件:Text1、Command1、Command2
'在属性窗口设置 Text1 的属性:HideSelection = False,MultiLine = True
Dim nStr As String
Private Sub Form_Load()
Command1.Caption = "查找": Command2.Caption = "下一个"
Text1.Text = "11111" & vbCrLf & "22222" & vbCrLf & "33333" & vbCrLf & "44444"
End Sub
Private Sub Command1_Click()
Dim Str1 As String
If nStr = "" Then nStr = "2"
Str1 = InputBox("请输入要查找的字符:", "查找", nStr)
If Str1 = "" Then Exit Sub
nStr = Str1
Call FindStr
End Sub
Private Sub Command2_Click()
If nStr = "" Then Call Command1_Click Else Call FindStr
End Sub
Private Sub FindStr()
Dim S As Long
S = Text1.SelStart + 1
If Text1.SelLength > 0 Then S = S + 1
Find1:
S = InStr(S, Text1.Text, nStr)
If S = 0 Then
If vbNo = MsgBox("已搜索到文档末尾,没有找到:" & nStr & vbCrLf & "是否从头重新搜索?", vbYesNo + vbInformation) Then Exit Sub
S = 1: GoTo Find1
End If
Text1.SelStart = S - 1: Text1.SelLength = Len(nStr)
End Sub
'添加控件:Text1、Command1、Command2
'在属性窗口设置 Text1 的属性:HideSelection = False,MultiLine = True
Dim nStr As String
Private Sub Form_Load()
Command1.Caption = "查找": Command2.Caption = "下一个"
Text1.Text = "11111" & vbCrLf & "22222" & vbCrLf & "33333" & vbCrLf & "44444"
End Sub
Private Sub Command1_Click()
Dim Str1 As String
If nStr = "" Then nStr = "2"
Str1 = InputBox("请输入要查找的字符:", "查找", nStr)
If Str1 = "" Then Exit Sub
nStr = Str1
Call FindStr
End Sub
Private Sub Command2_Click()
If nStr = "" Then Call Command1_Click Else Call FindStr
End Sub
Private Sub FindStr()
Dim S As Long
S = Text1.SelStart + 1
If Text1.SelLength > 0 Then S = S + 1
Find1:
S = InStr(S, Text1.Text, nStr)
If S = 0 Then
If vbNo = MsgBox("已搜索到文档末尾,没有找到:" & nStr & vbCrLf & "是否从头重新搜索?", vbYesNo + vbInformation) Then Exit Sub
S = 1: GoTo Find1
End If
Text1.SelStart = S - 1: Text1.SelLength = Len(nStr)
End Sub
参考资料: http://user.qzone.qq.com/32063270/blog/1242732133
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询