Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use open file dialog in VB 6?

Tags:

vb6

I want to select a file from the directory or other system. How to use open file dialog in VB 6?

like image 877
Gopal Avatar asked Jul 06 '09 04:07

Gopal


2 Answers

There's some example code in this question. Quoting:

In VB6, add the component:

  • Project > Components
  • On the Controls tab, choose Microsoft Common Dialog Control 6.0 (SP6)

Now on your form, add the new Common Dialog control from the toolbox

In code, you need:

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
like image 110
Ant Avatar answered Oct 01 '22 05:10

Ant


it needed the "1", but works great thank you

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

like image 44
Stroller Avatar answered Oct 01 '22 07:10

Stroller