求助高人啊,怎么才能在程序中调用出‘查找’关键词的对话框?这两天在网上一直没有搜到,急。若有高手相助的话非常感谢。
解决方案 »
- VB调用服务器上的COM+,出错:实时错误'70'拒绝的权限--在线等高手
- 注册表填加数值问题
- 50分,求好的想法~~聪明的,知识面宽的进来说说。
- 求教,VB中如何才能调用系统默认的打印机设置窗口?
- 我是新手帮忙怎样用VB在PC机上虚拟LED显示屏 。
- 新小白菜同学请教 望高手帮忙 不胜感激
- 续:数组格式化后并存为文本文件(现在存到数组),请暴风雨老大看一下,谢谢
- ××××十万火急××××
- 简单问题,分数多多!vb如何调用c写的标准函数
- 关于数据控件mshflexgrid,单元格拆分的问题!!
- 搞java的问个vb的WebBrowser的例子啊,懂的来。提示我最好写个里子
- VB控制I/O板卡的问题
lStructSize As Long
hwndOwner As Long
hInstance As Long
flags As Long
lpstrFindWhat As String
lpstrReplaceWith As String
wFindWhatLen As Integer
wReplaceWithLen As Integer
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type'调用 Common Dialog DLL
Private Declare Function FindText Lib "comdlg32.dll" Alias "FindTextA" _
(pFindreplace As FINDREPLACE) As Long
Private Declare Function ReplaceText Lib "comdlg32.dll" Alias "ReplaceTextA" _
(pFindreplace As FINDREPLACE) As Long
Dim frText As FINDREPLACE Private Sub cmdFind_Click()
FindText frText '调用查找对话框
End Sub
Private Sub cmdReplace_Click()
ReplaceText frText '调用替换对话框
End Sub
Private Sub form_Load()
With frText
.lpstrReplaceWith = "Replace Text"
.lpstrFindWhat = "Find Text"
.wFindWhatLen = 9
.wReplaceWithLen = 12
.hInstance = App.hInstance
.hwndOwner = Me.hWnd
.lStructSize = LenB(frText)
End With
End Sub
看下这个行不
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
'-----------------------------------------------
'浏览文件夹对话框
Private Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End TypePrivate Const MAX_PATH = 260
Private Const BIF_USENEWUI = &H40Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As LongPrivate Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As LongPrivate Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long'浏览文件夹
Public Function BrowseForFolder(hwndOwner As Long, _
sPrompt As String) As String Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo
With udtBI
.hwndOwner = hwndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_USENEWUI
End With lpIDList = SHBrowseForFolder(udtBI) If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
End If
If Right$(sPath, 1) <> "\" And sPath <> "" Then
sPath = sPath & "\"
End If
BrowseForFolder = sPathEnd Function'打开选择文件的对话框
Public Function BrowseForFile(lngHwnd As Long, _
ByVal Title As String) As String
Dim uOpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
With uOpenFile
.lStructSize = Len(uOpenFile)
.hwndOwner = lngHwnd
.hInstance = App.hInstance
sFilter = "数据库文件(*.mdb)" & Chr(0) & "*.mdb" & Chr(0)
.lpstrFilter = sFilter
.nFilterIndex = 1
.lpstrFile = String(257, 0)
.nMaxFile = Len(.lpstrFile) - 1
.lpstrFileTitle = .lpstrFile
.nMaxFileTitle = .nMaxFile
.lpstrInitialDir = App.Path
.lpstrTitle = Title
.flags = 0
End With
lReturn = GetOpenFileName(uOpenFile)
'等于0为用户选择了"取消"
If lReturn = 0 Then
BrowseForFile = ""
'add on
Frm_CnnAccess.CmdYes.Enabled = False
Else
BrowseForFile = Trim(uOpenFile.lpstrFile)
'add on
Frm_CnnAccess.TxtServerName.Text = Trim(uOpenFile.lpstrFile)
Frm_CnnAccess.CmdYes.Enabled = True
End If
End Function
不管怎么说,谢谢大家。有请aspower_多多包涵。