Click to See Complete Forum and Search --> : VB Common Dialog Box Control


Geist
12-22-2002, 01:07 PM
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.:(

muisejt
12-22-2002, 02:18 PM
Private Sub mnuOpen_Click()

With dlgCommon
.Filter = "*.exe|*.EXE"
.InitDir = "c:\windows"
End With
dlgCommon.ShowOpen

End Sub

Geist
12-23-2002, 01:20 PM
How do I allow more that one filetype through the filter?

bIOHZRd
12-23-2002, 02:48 PM
Even tho i know just about nothing in VB... im guessing


.Filter = "*.exe|*.EXE|*.ini|*.INI|*.mor|*.ext|*.her"

Geist
12-23-2002, 04:53 PM
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?

muisejt
12-23-2002, 11:36 PM
.Filter = "*.exe|*.EXE|*.bmp|*.BMP|*.txt|*.TXT"


works for me

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

Geist
12-24-2002, 08:40 PM
Huh. It doesn't seem to work for me. How odd. You just put the | symbol between each extension in the Filter string?

muisejt
12-25-2002, 11:53 AM
that's all I did, what version of VB are you using? I'm using 6

Geist
12-26-2002, 01:21 PM
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.

muisejt
12-26-2002, 08:25 PM
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:

.Filter = Executable|*.EXE|Bitmap|*.BMP|Text|*.TXT"


if you want to filter more than one extension at a time add a semi-colon between the extensions

.Filter = "exe and txt|*.EXE;*.TXT|"

Geist
12-27-2002, 12:57 PM
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.

muisejt
12-27-2002, 03:50 PM
dlg is what I was taught and use (see my first post)

Geist
12-27-2002, 07:31 PM
Great, dlg it is then. Thanx!