vb查找字符串 并选中它
Dim ii As Integer
Private Sub Command1_Click()
ii = InStr(ii + 1, Text1, Text2) '查找字符串出现的第一次位置
Text3 = ii
If ii = 0 Then Exit Sub
'在Text1中选中字符串
Text1.SelStart = ii - 1 '在Text1被选中字符开始位置
Text1.SelLength = Len(Text2) '在Text1被选中的字符的长度
Text1.SetFocus '在Text1中选中字符串
End Sub
Private Sub Form_Load()
Text1.Text = "zenmechaozhaogaishibachaowsa"
Text2.Text = "chao"
Text3.Text = "出现位置"
ii = 0
End Sub
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/ |