加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

VB---百例51--删除文件

发布时间:2020-12-16 22:39:31 所属栏目:大数据 来源:网络整理
导读:Option Explicit Private Sub Command1_Click() Dim killedfile As String,choicedfile As String 定义变量 Dim x If Right(Dir1.Path,1) = "" Then choicedfile = Dir1.Path + File1.FileName Else choicedfile = Dir1.Path + "" + File1.FileName End If

Option Explicit

Private Sub Command1_Click()
Dim killedfile As String,choicedfile As String 定义变量
Dim x
If Right(Dir1.Path,1) = "" Then
choicedfile = Dir1.Path + File1.FileName
Else
choicedfile = Dir1.Path + "" + File1.FileName
End If
killedfile = choicedfile 要删除的文件时所选文件
x = MsgBox("你确定要删除文件吗?",35,"确定框") 确认
If x = 6 Then 若返回值是6
Kill killedfile 将所选文件删除
MsgBox "文件已删除!请查看计算机上该文件所在的路径。","信息提示"
End If
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive

End Sub

成品图

选择文件路径的方法和实例49中的相类似

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读