What do I have to do, when creating an Open dialog box, to set a default directory and a filetype filter? I can't get it to work. I've tried setting the properies in the Custom property page, but it doesn't seem to work.:(
Printable View
What do I have to do, when creating an Open dialog box, to set a default directory and a filetype filter? I can't get it to work. I've tried setting the properies in the Custom property page, but it doesn't seem to work.:(
Code:Private Sub mnuOpen_Click()
With dlgCommon
.Filter = "*.exe|*.EXE"
.InitDir = "c:\windows"
End With
dlgCommon.ShowOpen
End Sub
How do I allow more that one filetype through the filter?
Even tho i know just about nothing in VB... im guessing
Code:.Filter = "*.exe|*.EXE|*.ini|*.INI|*.mor|*.ext|*.her"
I tried that. It doesn't work. I looked in the documentation (which is more advanced than I am, what with its references to objects and pointers and the like that I don't understand yet:o ) and it said the pipe symbol (|) separates a descriptor from an actual filter filetype. What?
By the way, how did you people get the VB code to come up between those little dividers in your posts?
works for meCode:.Filter = "*.exe|*.EXE|*.bmp|*.BMP|*.txt|*.TXT"
you can click the '#' in the formatting options or you can manually put the code tag in, [code] at the start and /code(in the brackets [ ]) at the end
Huh. It doesn't seem to work for me. How odd. You just put the | symbol between each extension in the Filter string?
that's all I did, what version of VB are you using? I'm using 6
Wait...the user can select one of two filetypes if I put two different filetypes in the filter but enter the extensions in all caps and all lower-case for each filetype. Do you need to do that? If so, why?
Also, how can I have it display all files that end in either of two filetype extensions, rather than displaying all files of one or all files of another? The example code in my "Teach Yourself Visual Basic 6" book doesn't work.
the first extension is what is displayed in the box and the second is the actual extension you want to filter so it could look like:
if you want to filter more than one extension at a time add a semi-colon between the extensionsCode:.Filter = Executable|*.EXE|Bitmap|*.BMP|Text|*.TXT"
Code:.Filter = "exe and txt|*.EXE;*.TXT|"
Ah, that makes perfect sense. I get it now. Thank you very much.
Say, one final thing--what is the three-letter prefix naming convention for Common Dialog Box controls? I think I've seen cdbName, dlgName, and cdlName.
dlg is what I was taught and use (see my first post)
Great, dlg it is then. Thanx!