总结
豆包 AI 助手文章总结

VB查找文本中文字

PHPz
发布: 2024-01-07 10:10:32
转载
1137人浏览过

VB查找文本中文字

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

VB查找文本

第一问:要有一个按钮,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

根据需要自己研究吧,嘿嘿

VB文本查找问题

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中文网其它相关文章!

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:Excel办公网网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
豆包 AI 助手文章总结
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号