1 Attachment(s)
[RESOLVED] Open a filedialog
Hello. Can one of these(please refer to attatchment) be opened with vb code? And if so how? I want the user to pick a certain file and when they click open, on the filedialog, it puts the path into a text box. I need to know if there is a command I can use to open windows default filedialog box and obtain a string from it. Thanks.
And while we are on the subject how do I populate some sort of list with a directory tree of a computers drive? Thats just in case I want to build a filedialog form in the future.
P.S. I really did do a search for it here first...:D
Re: Open a filedialog / Re: Variable Not Defined
Ok, when I run this program and click the open path button, I get a Compile Error: variable not defined. It highlights the Private Sub getpathbtn_Click() in yellow and it highlights the CommonDialog1 in blue. I only have a button named getpathbtn and a text field named dbpathtxt. I am running vb 6.0 enterprise w/service pack 6 on 98se.
Do I have to dim CommonDialog1 as something or maybe declare it? What about libraries? Do I need to go check a dll? And if I do, what do I dim it as, or what library do I click? See code below. Thanks again.:thumb:
VB Code:
Option Explicit
Dim mess As Integer
Private Sub getpathbtn_Click() 'highlights this whole line in yellow
On Error GoTo ErrHandler
With CommonDialog1 'highlights CommonDialog1 in blue
.CancelError = True
.Filter = "General Modules (*.mdb)|*.mdb"
.ShowOpen
If Not .FileName = "" Then
dbpathtxt.Text = .FileName
Else
mess = MsgBox("Not a valid path to a database.", vbOKOnly)
End If
End With
Exit Sub
ErrHandler:
Err.Clear
Exit Sub
End Sub
Re: [RESOLVED] Open a filedialog
How do you leave the file path away so you would only have text.txt ?
Re: [RESOLVED] Open a filedialog
Use the dialog's .FileTitle property
Re: [RESOLVED] Open a filedialog
Smooth LaVolpe.
It works.
Thanks.
Re: [RESOLVED] Open a filedialog
It often boils down to people now willing to explore properties of the given object. ;)