I wanted to use the Drive and File listboxes just to get the path of files on the network . Right now I'm using an inputbox for the user to type the path but they seem to have difficulty inputting the correct path.
How would I be able to make my own Drive & File listboxes with Icons(Just to make it more user friendly). IT Professional
If you just want the full path, can you not use the dialogue box control?
You will need to add it thru additional controls: Microsoft Common Dialogue Control
Will give the user the standard dialog box to select the file. When they click OK the path is placed into mypath.
To write your own drive and file listbox you would need to check for the drives available, and to be honest, I don't know how to do that one without just trying all possibilities and errortrapping the ones that fail along the lines of:
on error goto oops
for n = 66 to 90 'ascii codes for A-Z
drivename = asc+ ":"
chdir(drivename)
cmbDrives.additem (drivename)
backhere:
next n
oops:
drivename = ""
resume backhere
There is probably an easier, more elegant and faster way, but I don't know it.
To list folders and files, you'll need to list all the folders in a drive and list them in the combo box. Do the same for all the files in the current folder. On double clicking the foldername in the combo box, you'll need to list all the folders and files within that subfolder.
I could write the code, but I'd hate to do that to find your happy with the dialog box. If you do need more, I'll do it.
Here's the code I used to get the path of the files and get rid of the filename at the end of the path.
CommonDialog1.ShowOpen
filepath = CommonDialog1.Filename
strpos = instrrev(filepath,"\"
mypath = left(filepath,strpos - 1)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.