香烟虫图片:有关VB:怎么用instr()来编像Word那样的查找功能

来源:百度文库 编辑:高校问答 时间:2024/05/09 01:59:06
1、怎么用instr()来编像Word那样的查找功能?
2、在VB中怎么用shell来调用从通用对话框打开的文本文件?
3、用VB怎么才能在某窗体的显示VB的版本信息(在帮助菜单下)?

问题1.
'放在一个标准模块中,设置工程启动为"Sub Main()"
Option Explicit

Sub main()
Dim SourceStr As String, wStr As String
'待查找的字符串
SourceStr = "abcdef1Google" & _
"ghijkl2百度搜索mnopqrs3Yahootuvwxyz"
'要查找的内容
wStr = "o"
Dim pos As Long
pos = InStr(1, SourceStr, wStr)
Do While pos <> 0
Debug.Print pos
pos = InStr(pos + 1, SourceStr, wStr)
Loop
End Sub
问题2.
没听说过Shell可以调用通用对话框的,要么用控件,
要么调用API实现.
问题3.
'主版本
App.Major
'次版本
App.Minor
'修订次数
App.Revision
'版权
App.LegalCopyright
'描述
App.FileDescription
'合法商标
App.LegalTrademarks

用资料

问题2的意思应该是这样的吧

on error resume next
commondialog1.cancelerr=true
commondialog1.filter= "*.txt|*.txt"
commondialog1.showopen
if err then
msgbox "没有选择文件"
else
shell "notepad " & commondialog1.filename, vbnormalfocus
end if