我现在想进行路径选择而不是文件选择
用commondialog行吗?
要设置什么属性?
不行的话
要用什么控件?
谢谢
用commondialog行吗?
要设置什么属性?
不行的话
要用什么控件?
谢谢
解决方案 »
- 如何在对话框的 ShowOpen方法中给“取消”按钮设置一个Exit sub
- 用VB语句或SQL语句如何测出已经安装了SQL SERVER
- Dim CharSingle As String * 1表示什么?
- 什么是双向兼容设置?
- 在Windows上执行Dos程序错误怎么解决?
- 想问一问VB中计量单位的问题
- 好几个问题,急待解决!!!
- 如何判断本地连接已启用/已禁止
- 窗体标题到底是什么字符???
- 请教关于mouse_down,mouse_up,和mouse_move 的应用
- 打印工作证,怎么竖着打啊,等待指教!请进,附代码。
- ++++++++++++++急!!!!!!!!关于生产管理系统的产品结构和物料需求!
commondialog选择文件包括完整的路径 应该可以
试试.FILENAME属性吧
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 Type
Const BIF_RETURNONLYFSDIRS = 1
Const BIF_NEWDIALOGSTYLE = &H40
Const BIF_EDITBOX = &H10
Const MAX_PATH = 260Const BIF_BROWSEFORCOMPUTER = &H1000
Const BIF_BROWSEFORPRINTER = &H2000
Const BIF_BROWSEINCLUDEFILES = &H4000
Const BIF_DONTGOBELOWDOMAIN = &H2
Const BIF_RETURNFSANCESTORS = &H8
Const BIF_STATUSTEXT = &H4
Const BIF_USENEWUI = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)
Private 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 Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Load()
Dim iNull As Integer, lpIDList As Long, lResult As Long
Dim sPath As String, udtBI As BrowseInfo With udtBI
.hWndOwner = Me.hWnd
.lpszTitle = lstrcat("C:\", "")
.ulFlags = BIF_BROWSEINCLUDEFILES
End With lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
SHGetPathFromIDList lpIDList, sPath
CoTaskMemFree lpIDList
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
End If MsgBox sPath
End Sub
如果使用CommonDialog必须选择文件,才可以得到带文件名的完整路径。
“另存为”
“颜色”
“字体”
“打印”
要使用 CommonDialog 控件 若未添加 CommonDialog 控件,则应从“工程”菜单中选定“部件”,将控件添加到工具箱中。在标记对话的“控件”中找到并选定控件,然后单击“确定”按钮。
单击工具箱中的“CommonDialog”控件并在窗体上绘制该控件。
在窗体上绘制 CommonDialog 控件时,控件将自动调整大小。象 Timer 控件一样,CommonDialog 控件在运行时不可见。运行时,请适当使用下表所列方法显示需要的对话。 方法 显示的对话
ShowOpen 打开
ShowSave 另存为
ShowColor 颜色
ShowFont 字体
ShowPrinter 打印
ShowHelp 调用 Windows“帮助”
然后弄到字节数组当中通过mscomm控件发送吗?
如果可以 又该如何实现呢?
Bas COde
code:--------------------------------------------------------------------------------’This module contains all the declarations to use the
’Windows 95 Shell API to use the browse for folders
’dialog box. To use the browse for folders dialog box,
’please call the BrowseForFolders function using the
’syntax: stringFolderPath=BrowseForFolders(Hwnd,TitleOfDial
og)
’
’For contacting information, see other moduleOption ExplicitPublic 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 TypePublic Const BIF_RETURNONLYFSDIRS = 1
Public Const MAX_PATH = 260Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As LongPublic Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String
’declare variables to be used
Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo ’initialise variables
With udtBI
.hwndOwner = hwndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With ’Call the browse for folder API
lpIDList = SHBrowseForFolder(udtBI)
’get the resulting string path
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 ’If cancel was pressed, sPath = ""
BrowseForFolder = sPathEnd Function
Form Code Private Sub cmdServerBrowse_Click()
txtDatabasePath.Text = BrowseForFolder(hwnd, "Please select a Server folder.")
End Sub
你运行就知道了
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As LongPrivate Declare Function SHGetSpecialFolderLocation Lib _
"shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder _
As Long, pIdl As ITEMIDLIST) As LongPrivate Declare Function SHGetFileInfo Lib "Shell32" Alias _
"SHGetFileInfoA" (ByVal pszPath As Any, ByVal _
dwFileAttributes As Long, psfi As SHFILEINFO, ByVal _
cbFileInfo As Long, ByVal uFlags As Long) As LongPrivate Declare Function ShellAbout Lib "shell32.dll" Alias _
"ShellAboutA" (ByVal hwnd As Long, ByVal szApp As _
String, ByVal szOtherStuff As String, ByVal hIcon As Long) _
As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pIdl As Long, ByVal _
pszPath As String) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)Const MAX_PATH = 260Private Type SHITEMID
cb As Long
abID() As Byte
End TypePrivate Type ITEMIDLIST
mkid As SHITEMID
End TypePrivate Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End TypePrivate Type SHFILEINFO
hIcon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80
End Type
Private Function GetFolderValue(wIdx As Integer) As Long
If wIdx < 2 Then
GetFolderValue = 0
ElseIf wIdx < 12 Then
GetFolderValue = wIdx
Else
GetFolderValue = wIdx + 4
End If
End FunctionPrivate Sub Command1_Click()
Dim BI As BROWSEINFO
Dim nFolder As Long
Dim IDL As ITEMIDLIST
Dim pIdl As Long
Dim sPath As String
Dim SHFI As SHFILEINFO
Dim m_wCurOptIdx As Integer
Dim txtPath As String
Dim txtDisplayName As String
With BI
.hOwner = Me.hwnd
nFolder = GetFolderValue(m_wCurOptIdx)
If SHGetSpecialFolderLocation(ByVal Me.hwnd, ByVal nFolder, IDL) = NOERROR Then
.pidlRoot = IDL.mkid.cb
End If
.pszDisplayName = String$(MAX_PATH, 0)
.lpszTitle = "Browsing is limited to: "
.ulFlags = 0
End With
txtPath = ""
txtDisplayName = ""
pIdl = SHBrowseForFolder(BI)
If pIdl = 0 Then Exit Sub
sPath = String$(MAX_PATH, 0)
SHGetPathFromIDList ByVal pIdl, ByVal sPath txtPath = Left(sPath, InStr(sPath, vbNullChar) - 1)
txtDisplayName = Left$(BI.pszDisplayName, _
InStr(BI.pszDisplayName, vbNullChar) - 1)
SHGetFileInfo ByVal pIdl, 0&, SHFI, Len(SHFI), _
SHGFI_PIDL Or SHGFI_ICON Or SHGFI_SMALLICON
SHGetFileInfo ByVal pIdl, 0&, SHFI, Len(SHFI), _
SHGFI_PIDL Or SHGFI_ICON
CoTaskMemFree pIdl
MsgBox "你选择的文件夹是" + Chr(13) + Chr(10) + txtPath
End Sub
Private Sub Command2_Click() Dim rsTest As New ADODB.Recordset
Dim strSQL As String strSQL = "select * from DE where 分件号 like '%" + Text4.Text + "%'"
rsTest.Open strSQL, GCon
If rsTest.RecordCount = 0 Then
MsgBox "没有找到匹配记录!", vbInformation, "提示"
Else
Set DataGrid1.DataSource = rsTest
End If好,问题 来了
请问,我要如何写 才能用鼠标 点选 某条查询出来的记录时 同时把 该条记录中的某3个字段的值分别显示在3个不同的Text 上呢??
原来是可以的
我原来试过好像不行
谢谢了!
问题解决