怎么在vb下打开选择多个文件的对话框???我在编写程序的时候,使用了一个对话框控件来选择多个文件,但是这个控件比较老,好象是win95,98的,有没有最新的控件???请指教!
解决方案 »
- 急求VB高手帮忙!
- vb窗口颜色问题
- vb6.0开发的active dll,asp在引用时对象不支持此属性或方法,在线等
- 有没有一个字符串函数能够实现返回一个字符在字符串中出现的次数?
- 如何用webbrowser获取框架内页面的代码,急!!!
- 多文檔如何加個背景圖能自動適應1024*768 和 800*600?
- 高分询问(100分):Why imgedit.ocx做的图象显示部分,在不同的操作系统中,怎么有的实现黑屏!!
- 怎样判断当前文件夹下是否有指定文件?
- ******我想将一列用循环填满数据,出现了问题,有代码******
- 是csdn的救火队员的进来
- 如何让某个窗口获得焦点
- 请问这样如何来设计:后台是SQLSERVER2000,在VB里要实现C/S的方式?请教
CommonDialog1.flags = cdlOFNAllowMultiselect Or cdlOFNExplorerCommonDialog1.FileName 反回路径和文件名,每个文件名用空格格开.
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As LongPublic Type OPENFILENAME
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 TypeCommand1_Click()事件中:
Dim ofn As OPENFILENAME
Dim FileName(50) As StringDim a As Long
Dim i As Integer, j As Integer
Dim tStr As String
Dim FileNum As Integerofn.lStructSize = Len(ofn)
ofn.hwndOwner = Form1.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = "所有文件" + Chr$(0) + "*.*"
ofn.lpstrFile = Space$(500)
ofn.nMaxFile = 600
ofn.lpstrFileTitle = Space$(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = CurDir
ofn.lpstrTitle = "打开"
ofn.flags = &H200 Or &H80000 Or &H4a = GetOpenFileName(ofn)
tStr = Trim$(ofn.lpstrFile)If (a) Then
j = 1
i = InStr(j, tStr, Chr(0))
j = i + 1
If i = 0 Then Exit Sub FileName(0) = Mid(tStr, 1, i - 1) For i = 1 To Len(tStr) i = InStr(j, tStr, Chr(0))
If i = Len(tStr) Then Exit Sub
FileNum = FileNum + 1
FileName(FileNum) = Mid(tStr, j, i - j)
List1.AddItem FileName(FileNum)
j = i + 1
Next i
End If数组FileName(0)为路径,下标在1以上为文件名
Dim i As Integer, title As String, FileNames As String
ComDialogFax.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNLongNames
ComDialogFax.Filter = "All Excel Files (*.xls)|*.xls|All files (*.*)|*.*"
ComDialogFax.FilterIndex = 1
ComDialogFax.InitDir = "C:\"
ComDialogFax.FileName = ""
ComDialogFax.CancelError = False
ComDialogFax.ShowOpen
i = InStrRev(ComDialogFax.FileName, "\") '
title = Left(ComDialogFax.FileName, i) ' Ŀ¼
FileNames = Mid(ComDialogFax.FileName, i + 1) ' all selectes files
Do While Len(FileNames) > 0
title = GetLeftWords(FileNames, Chr(0))
MsgBox title
Loop
End SubFunction GetLeftWords(s As String, ByVal Ch As String) As String
Dim i As Long
i = InStr(s, Ch)
If i > 0 Then
GetLeftWords = Left(s, i - 1)
s = Mid(s, i + Len(Ch))
Else
GetLeftWords = s
s = vbNullString
End If
End Function