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, " ")
'Output
Me.Print AR2(LBound(AR2)) & Space(2);
Next i
End Sub
First question: There needs to be one button and two textboxes
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
Second question:
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
Do your own research as needed, hehe
3 text boxes, 1 button
text1 is the text, text2 displays the results, text3 needs to find the text
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
The above is the detailed content of Find Chinese characters in text using VB. For more information, please follow other related articles on the PHP Chinese website!