求3段代码,分别是1 VB 选择文件,并获得文件全名 2 vb 弹出保存对话框,返回保存文件全名 3 选择文件夹

2024-12-03 11:03:52
推荐回答(1个)
回答(1):

第一个功能,第二个功能都在下面的代码里。
需要添加1个CommonDialog 2个text 2个Command
Private Sub Command1_Click()
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileTitle
Text2.Text = CommonDialog1.FileName
End Sub

Private Sub Command2_Click()
CommonDialog1.ShowSave
Text1.Text = CommonDialog1.FileTitle
Text2.Text = CommonDialog1.FileName
End Sub

Private Sub Form_Load()
Text1.Text = "文件名"
Text1.Text = "文件路径"
Command1.Caption = "打开文件"
Command1.Caption = "保存文件"
End Sub
第三个功能
需要添加1个text 1个Dir 1个Drive
Private Sub Dir1_Change()
Text1.Text = Dir1.Path
End Sub

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

Private Sub Form_Load()
Text1.Text = "文件夹路径"
End Sub