Results 1 to 7 of 7

Thread: open file dialog help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    292

    Question open file dialog help



    can anyone guide me? i read up on how to open the openfile dialog box in vb6 but it said to drag the openfiledialog control onto the form but i have searched everywhere and i cant find that control
    does anyone know how to get it

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: open file dialog help

    Projects/Components/Microsoft Common Dialog Control

  3. #3
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: open file dialog help

    You have to add the component to your project first.

    Go to Project> Component
    scrol down
    then check Microsoft Common Dialog Control
    then click ok

    you should have the dialog control on your toolbox thing
    then you add it like any other component (click, drag)

    HTH
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    292

    Re: open file dialog help

    thanks for the help so far
    i have read up on this but what this book told me to do didnt work so how would i get the open file dialog box to come up once it is on the form

  5. #5
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: open file dialog help

    Here's one that i used to open text files if you want to change that you can change the extension to whatever you want to filter for (ex: .xls, .doc ....) or you can change it to not filter.

    VB Code:
    1. Private Sub Command1_Click()
    2.    
    3.    
    4.     strFilter = "Text (*.txt)|*.txt|All Files (*.*)|*.*"
    5.     cdMain.Filter = strFilter
    6.    
    7.     'Open the common dialog in open mode
    8.     cdMain.ShowOpen
    9.    
    10.     txtOpen.Text = cdMain.FileName
    11.    
    12.    
    13. End Sub

    For this bit of code the common dialog control was renamed to cdMain.

    HTH
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Posts
    292

    Re: open file dialog help

    how do select a specific folder to be the one which appears when the open file dialog is first run

  7. #7
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: open file dialog help

    Here you go. Just add the InitDir command and set it equal to the directory that you want.

    VB Code:
    1. Private Sub Command1_Click()
    2.    
    3.    
    4.     strFilter = "Text (*.txt)|*.txt|All Files (*.*)|*.*"
    5.     cdMain.Filter = strFilter
    6.     cdMain.InitDir = "C:\YourDirectory"
    7.     'Open the common dialog in open mode
    8.     cdMain.ShowOpen
    9.    
    10.     txtOpen.Text = cdMain.FileName
    11.    
    12.    
    13. End Sub

    HTH
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

Posting Permissions

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



Click Here to Expand Forum to Full Width