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 01 29 01 03 00 00 00 00 00 00 00 F4 400000 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中文網其他相關文章!