woottond
asked on
File Chooser - want to make a form "return" a file name
I'm sure some one has done this before... what I want to have is a button called "Open File" on my main form. I want it so that when I hit this button it loads the "File Chooser" form and lets the user select a file
What I REALLY want though is for the form to return the file name (or a -1 for a fail. However, forms, to the best of my knowledge don't have returns... I have currently got around this by creating a driver function that waits for the user to select a file or cancels... when the user makes a choice the function closes the form and returns either the file name or a -1 to indicate no file chosen.
Any tips or code GREATLY appreciated...
What I REALLY want though is for the form to return the file name (or a -1 for a fail. However, forms, to the best of my knowledge don't have returns... I have currently got around this by creating a driver function that waits for the user to select a file or cancels... when the user makes a choice the function closes the form and returns either the file name or a -1 to indicate no file chosen.
Any tips or code GREATLY appreciated...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks hes!
I made a mistake and missed that dialog box - had a funny feeling when I was writing the form that I was doing it the hard way - and that it was weird that there wasn't a dialog box already...
THANKS!!!
btw - trkcorp - I was doing something quite simular before, like what you had suggested - The problem is you have to know when the file has been choosen, which means you must setup some kinda waitFor event... which was the part I had problems with (code wise its easy - I just don't like it...)
I made a mistake and missed that dialog box - had a funny feeling when I was writing the form that I was doing it the hard way - and that it was weird that there wasn't a dialog box already...
THANKS!!!
btw - trkcorp - I was doing something quite simular before, like what you had suggested - The problem is you have to know when the file has been choosen, which means you must setup some kinda waitFor event... which was the part I had problems with (code wise its easy - I just don't like it...)
ASKER
Fast, Concise, Easy
(took 10 minutes!!!)
Thanks Hes
(took 10 minutes!!!)
Thanks Hes
Ex: (Main Form named Form1)
Option Explicit
Public sFN as string
called form (Form2)
Form1.sFN = "Any Value"
Now Form1 can reference the variable sFN as can Form2...