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

VB工程--百例49--显示文件路径

发布时间:2020-12-16 22:39:32 所属栏目:大数据 来源:网络整理
导读:Option Explicit Private Sub Dir1_Change() File1.Path = Dir1.Path Label1.Caption = Dir1.Path End Sub Private Sub Drive1_Change() Dir1.Path = Drive1.Drive Label1.Caption = Drive1.Drive End Sub Private Sub File1_Click() If Right(Dir1.Path,1)

Option Explicit

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

Label1.Caption = Dir1.Path
End Sub

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

Label1.Caption = Drive1.Drive

End Sub

Private Sub File1_Click()
If Right(Dir1.Path,1) = "" Then红字是right语法;若目录路径最右侧的字符为""
Label1.Caption = Dir1.Path & File1.FileName 显示所选择的文件名
Else 若目录路径最右侧的字符不是为""
Label1.Caption = Dir1.Path & "" & File1.FileName在显示的文件名前添加""

End If
End Sub

Private Sub Form_Load()
Dir1.Path = Drive1.Drive文件所在的驱动器与目录项符合
File1.FileName = Dir1.Path文件的路径是目录列表中的路径

End Sub

成品图

此题和VB百例48相类似

(编辑:李大同)

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

    推荐文章
      热点阅读