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

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相类似

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...