VB工程--百例53--文件改名

前端之家收集整理的这篇文章主要介绍了VB工程--百例53--文件改名前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Option Explicit

Private Sub Command1_Click()
Dim oldname As String
Dim newname As String
If Right(Dir1.Path,1) = "\" Then
oldname = Dir1.Path & File1.FileName
Else
oldname = Dir1.Path & "\" & File1.FileName
End If
newname = InputBox("请输入新文件名称","输入框")
If newname <> "" Then
Name oldname As newname
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



成品图

原文链接:https://www.f2er.com/vb/260398.html

猜你在找的VB相关文章