Visual Basic 6.0通用对话窗口
来源:百度知道 编辑:UC知道 时间:2024/05/14 10:32:56
FileName.Text = ofn.lpstrFile 好象错了。
----------窗体--------------
Option Explicit
Private Sub FileOpen_Click()
Dim ofn As OPENFILENAME
Dim rtn As String
ofn.lStructSize = Len(ofn)
ofn.hwndOwner = Me.hWnd
ofn.hInstance = App.hInstance
ofn.lpstrFilter = "所有文件"
ofn.lpstrFile = Space(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = App.Path
ofn.lpstrTitle = "打开文件"
ofn.flags = 6148
rtn = GetOpenFileName(ofn)
If rtn >= 1 Then
FileName.Text = ofn.lpstrFile
Else
FileName.Text = "Cancel Was Pressed"
End If
End Sub
---------模块-----------
Option Explicit
Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long