Private Sub Command1_Click()
Dim AR() As String, AR2() As String
sTxt = "2 01 01 00 00 00 00 00 00 00 F4 44 0C 00 08 01 29 01 03 00 00 00 00 00 00 00 F4 44 0C 00 08 01 D3 01 04 00 00 00 00 00 00 00 F4 44 0C 00 08 01 2A 01 06 00 00 00 00 00 00 00 F4 44 0C 00 08 01"
AR = Split(sTxt, "D3 01")
L = LBound(AR) + 1
U = UBound(AR)
For i = L To U
tmp = Trim(AR(i))
AR2 = Split(tmp, " ")
'输出
Me.Print AR2(LBound(AR2)) & Space(2);
Next i
End Sub
第一问:要有一个按钮,2个textbox
Private Sub Command1_Click()
Dim a As Integer
a = InStr(1, Text1.Text, Text2.Text, vbTextCompare)
Text1.SetFocus
Text1.SelStart = a - 1
Text1.SelLength = Len(Text2.Text)
End Sub
第二问:
Private Sub Command1_Click()
Dim a As Integer
a = InStr(1, Text1.Text, Text2.Text, vbTextCompare)
If a > 0 Then
Text1.SetFocus
Text1.SelStart = a - 1
SendKeys "{down}"
End If
End Sub
根据需要自己研究吧,嘿嘿
3个文本框,1个按钮
text1中是文本,text2显示结果,text3需要查找的文字
Private Sub Command1_Click()
Dim p As Long, s As Long
Dim L As String
p = -1
Do While True
s = p + 2
p = InStr(s + 1, Text1.Text, vbCrLf)
If p = 0 Then
Text1.SelStart = s - 1
Text1.SelLength = Len(Text1.Text) - s + 1
Else
Text1.SelStart = s - 1
Text1.SelLength = p - s + 1
End If
If InStr(1, Text1.SelText, Text3.Text) > 0 Then
If Text2.Text = "" Then
Text2.Text = Text1.SelText
Else
Text2.Text = Text2.Text & vbCrLf & Text1.SelText
End If
End If
If p = 0 Then Exit Do
Loop
End Sub
以上是VB查找文本中文字的详细内容。更多信息请关注PHP中文网其他相关文章!