Commondialog控件,请大家帮帮忙,,谢谢...
如下图我想单击一下command1弹出一个Commondialog通用对话框,
通用对话的框的Flags属性取值512(可多选),选择几个文件后,单击确定,这几个所选文件的
名字就能分别显示在Text1的控件组里,改如果写呀...请各位高手帮忙解决,或给点思路..谢谢.
[解决办法]
Dim I As Long, J() As String CommonDialog1.ShowOpen J = Split(CommonDialog1.FileName, Chr(32)) For I = 0 To UBound(J) Debug.Print """" & J(I) & """" Next
[解决办法]
Private Sub Command1_Click() Dim a() As String, i As Integer, num As Integer For i = 0 To Text1.Count - 1 Text1(i).Text = "" Next CommonDialog1.FileName = "" ' 设置“CancelError”为 True CommonDialog1.CancelError = True On Error GoTo ErrHandler ' 设置过滤器 CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files" & _ "(*.txt)|*.txt|Batch Files (*.bat)|*.bat" ' 指定缺省的过滤器 CommonDialog1.FilterIndex = 1 '允许多重选择 CommonDialog1.Flags = cdlOFNAllowMultiselect '设置打开的文件名的最大尺寸 CommonDialog1.MaxFileSize = 4096 ' 显示“打开”对话框 CommonDialog1.ShowOpen '放入textbox数组 a = Split(CommonDialog1.FileName) num = UBound(a) If num > Text1.Count Then num = Text1.Count For i = 1 To num Text1(i - 1) = a(i) Next Exit Sub ErrHandler: ' 用户按了“取消”按钮 Exit SubEnd Sub
[解决办法]