VB Common Dialog Box Control

Sharky Forums


Results 1 to 13 of 13

Thread: VB Common Dialog Box Control

  1. #1
    Catfish Geist's Avatar
    Join Date
    Jul 2002
    Location
    Everywhere
    Posts
    105

    VB Common Dialog Box Control

    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.
    I should write an ethnography about internet discussion boards.

  2. #2
    Super Bunny Mod muisejt's Avatar
    Join Date
    Dec 2000
    Location
    Nova Scotia, Canada
    Posts
    9,833
    Code:
    Private Sub mnuOpen_Click()
        
        With dlgCommon
            .Filter = "*.exe|*.EXE"
            .InitDir = "c:\windows"
        End With
        dlgCommon.ShowOpen
        
    End Sub
    If your sig is longer than your post then type more.

  3. #3
    Catfish Geist's Avatar
    Join Date
    Jul 2002
    Location
    Everywhere
    Posts
    105
    How do I allow more that one filetype through the filter?
    I should write an ethnography about internet discussion boards.

  4. #4
    Reef Shark
    Join Date
    Feb 2001
    Location
    Minot, ND
    Posts
    387
    Even tho i know just about nothing in VB... im guessing

    Code:
    .Filter = "*.exe|*.EXE|*.ini|*.INI|*.mor|*.ext|*.her"
    My Site -=[http://hzrd.us]=-
    Puter #1
    Athlon XP 2600+ @ 2.2GHz 11.5x190 | 2x512mb Corsair c2 3200 | Radeon 9800 Pro |Asus a7nx8 | WD 120GB/ Seagate SATA 120GB x 2


    Puter #2
    T'bird 1000@1224 | 768 Crucial PC133 | GeForce2 MX 32mb eVGA | Abit KT7a-Raid | 40gb ata/100 WD | Sound Blaster Live!

  5. #5
    Catfish Geist's Avatar
    Join Date
    Jul 2002
    Location
    Everywhere
    Posts
    105
    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 ) 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?
    I should write an ethnography about internet discussion boards.

  6. #6
    Super Bunny Mod muisejt's Avatar
    Join Date
    Dec 2000
    Location
    Nova Scotia, Canada
    Posts
    9,833
    Code:
    .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
    If your sig is longer than your post then type more.

  7. #7
    Catfish Geist's Avatar
    Join Date
    Jul 2002
    Location
    Everywhere
    Posts
    105
    Huh. It doesn't seem to work for me. How odd. You just put the | symbol between each extension in the Filter string?
    I should write an ethnography about internet discussion boards.

  8. #8
    Super Bunny Mod muisejt's Avatar
    Join Date
    Dec 2000
    Location
    Nova Scotia, Canada
    Posts
    9,833
    that's all I did, what version of VB are you using? I'm using 6
    If your sig is longer than your post then type more.

  9. #9
    Catfish Geist's Avatar
    Join Date
    Jul 2002
    Location
    Everywhere
    Posts
    105
    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.
    Last edited by Geist; 12-26-2002 at 02:28 PM.
    I should write an ethnography about internet discussion boards.

  10. #10
    Super Bunny Mod muisejt's Avatar
    Join Date
    Dec 2000
    Location
    Nova Scotia, Canada
    Posts
    9,833
    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:
    Code:
    .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
    Code:
    .Filter = "exe and txt|*.EXE;*.TXT|"
    If your sig is longer than your post then type more.

  11. #11
    Catfish Geist's Avatar
    Join Date
    Jul 2002
    Location
    Everywhere
    Posts
    105
    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.
    Last edited by Geist; 12-27-2002 at 02:02 PM.
    I should write an ethnography about internet discussion boards.

  12. #12
    Super Bunny Mod muisejt's Avatar
    Join Date
    Dec 2000
    Location
    Nova Scotia, Canada
    Posts
    9,833
    dlg is what I was taught and use (see my first post)
    If your sig is longer than your post then type more.

  13. #13
    Catfish Geist's Avatar
    Join Date
    Jul 2002
    Location
    Everywhere
    Posts
    105
    Great, dlg it is then. Thanx!
    I should write an ethnography about internet discussion boards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •