注册 登录
编程论坛 VB6论坛

编程实现选中文字,如何实现?

yuma 发布于 2022-02-09 10:28, 1644 次点击
编程实现选中文字,如何实现?
像下面这样,图中“多次”二字被选中:
只有本站会员才能查看附件,请 登录
6 回复
#2
约定的童话2022-02-09 14:28
从第一个字符开始循环到倒数第二个,每次2字节组词判断是否是“多次”字样...
#3
yuma2022-02-09 17:52
判断没有用,关键是如何选中它。
#4
约定的童话2022-02-09 18:09
回复 3楼 yuma
选中的下一步干嘛?复制?
#5
时光流逝2022-02-09 20:09
用TextBox的SelStart和SelLength属性就可以了
#6
wen35232022-02-09 21:43
曾经有一项目,好似有点类似吧,
Private Sub RichTextBox1_Change(Index As Integer)
 Dim Mun字数 As Integer
  Mun字数 = Len(Trim$(Text2.Text))
If Mun字数 >= 1 Then
 If Index = 3 And RichTextBox1(3) <> "" Then
   RichTextBox1(3).SelStart = 0
   RichTextBox1(3).SelLength = (Len(Trim$(RichTextBox1(3).Text)))
   RichTextBox1(3).SelColor = vbBlack
     For i = 1 To (Len(Trim$(RichTextBox1(3).Text)) - Mun字数)
       If Text2 = Mid(Trim$(RichTextBox1(3).Text), i, Mun字数) Then
          RichTextBox1(3).SelStart = i - 1
          RichTextBox1(3).SelLength = Mun字数
          RichTextBox1(3).SelColor = vbRed
       End If
     Next i
 End If
End If
#7
yuma2022-02-11 11:17
以下是引用时光流逝在2022-2-9 20:09:10的发言:

用TextBox的SelStart和SelLength属性就可以了

这个可以。
1