suhani
asked on
User input from Textbox or CommonDialog
I have provided both Textbox and CommonDialog for the user to enter a filename. So far I just managed to get the user to click a button to call the CommonDialog control and when a file is selected, then the filename will appear in the Textbox. But if the user straight away write down the filename in the Textbox, then there will be an error.
How can I make the user to enter the filename either using the Textbox or the CommonDialog control?
Below is the coding:
Private Sub Button1_Click()
CommonDialog1.showOpen
txtFilename = CommonDialog1.Filename
InputFile = txtFilename
End Sub
How can I make the user to enter the filename either using the Textbox or the CommonDialog control?
Below is the coding:
Private Sub Button1_Click()
CommonDialog1.showOpen
txtFilename = CommonDialog1.Filename
InputFile = txtFilename
End Sub
Just in case, try this:
Private Sub Button1_Click()
Dim InputFile as String
CommonDialog1.filter = "All Files (*.*)|*.*"
CommonDialog1.showOpen
If CommonDialog1.filename <> null then
txtFilename.text = CommonDialog1.Filename
end if
InputFile = txtFilename.text
End Sub
Private Sub Button1_Click()
Dim InputFile as String
CommonDialog1.filter = "All Files (*.*)|*.*"
CommonDialog1.showOpen
If CommonDialog1.filename <> null then
txtFilename.text = CommonDialog1.Filename
end if
InputFile = txtFilename.text
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim InputFile as String
CommonDialog1.filter = "All Files (*.*)|*.*"
CommonDialog1.showOpen
txtFilename.text = CommonDialog1.Filename
InputFile = txtFilename.text
End Sub