📄 form1.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "删除文件"
Height = 495
Left = 1800
TabIndex = 1
Top = 2160
Width = 1215
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 960
Top = 2160
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command1
Caption = "打开文件"
Height = 495
Left = 1800
TabIndex = 0
Top = 1320
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT _
) As Long
Dim MyFile As String
'删除文件函数
Function ShellDelete(FileName As String)
Dim SHFileOp As SHFILEOPSTRUCT
FileName = FileName & vbNullChar
With SHFileOp
.wFunc = FO_DELETE
.pFrom = FileName
.fFlags = FOF_NOCONFIRMATION
End With
ShellDelete = SHFileOperation(SHFileOp)
End Function
Private Sub Command1_Click()
' 设置“CancelError”为 True
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' 设置标志
CommonDialog1.Flags = cdlOFNHideReadOnly
' 设置过滤器
CommonDialog1.Filter = "All Files (*.*)"
' 指定缺省的过滤器
CommonDialog1.FilterIndex = 2
' 显示“打开”对话框
CommonDialog1.ShowOpen
MyFile = CommonDialog1.FileName
Exit Sub
ErrHandler:
' 用户按了“取消”按钮
End Sub
Private Sub Command2_Click()
ShellDelete (MyFile)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -