Tác giả: truongphu
Mô tả: trong loạt bài VBSCRIPT để làm VB6 phong phú hơn.
trong bài dưới đây trình bày mở hộp thoại open, file lọc là bmp, thư mục mặc định là c:\windows\system32. Có khai thêm hàm API ShellExecute để phối hợp mở một file đã chọn. Bạn đọc có thể edit lại code tùy nhu cầu
lưu ý: Chỉ mới test trên WinXP SP2
Code: Select all
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Form_Load()Set objDialog = CreateObject("UserAccounts.CommonDialog")objDialog.Filter = "Bitmap|*.bmp|All Files|*.*"objDialog.Flags = &H200objDialog.FilterIndex = 1objDialog.InitialDir = "c:\windows\system32"intResult = objDialog.ShowOpen If intResult = 0 Then EndElse ShellExecute Me.hwnd, vbNullString, objDialog.FileName, vbNullString, "C:\", 1End IfEnd Sub