2009-07-06 64 views

Trả lời

15

Có một số mã mẫu trong this question. Trích dẫn:

Trong VB6, thêm các thành phần:

  • Project> Components
  • Trên tab Controls, chọn Microsoft Common Dialog kiểm soát 6.0 (SP6)

Bây giờ vào mẫu của bạn, thêm điều khiển Hộp thoại chung mới từ hộp công cụ

Trong mã, bạn cần:

CommonDialog1.Filter = "Apps (*.txt)|*.txt|All files (*.*)|*.*" 
CommonDialog1.DefaultExt = "txt" 
CommonDialog1.DialogTitle = "Select File" 
CommonDialog1.ShowOpen 

'The FileName property gives you the variable you need to use 
MsgBox CommonDialog1.FileName 
1

nó cần có quyền "1", nhưng hoạt động tuyệt vời cảm ơn bạn

CommonDialog1.Filter = "Apps (*.txt)|*.txt|All files (*.*)|*.*" 
CommonDialog1.DefaultExt = "txt" 
CommonDialog1.DialogTitle = "Select File" 
CommonDialog1.ShowOpen 

'Thuộc tính FileName cho bạn biến bạn cần phải sử dụng MsgBox CommonDialog1.FileName

+0

tôi sửa đổi câu trả lời từ @Ant – Rob

Các vấn đề liên quan