Results 1 to 7 of 7

Thread: Browse

  1. #1

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    Is there anyway to hit a command button and have the windows browse box come up and when they click on a file vb can put the address of the file in a text box. Also can you make it so that it only reads exe files or say scr files or anything like that? Basically just like the start run.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Add a Microsoft Common Dialog Control to your form and use this code:
    Code:
        On Error Resume Next
        
        With CommonDialog1
            .CancelError = True
            .Filter = "Custom Selection (*.exe, *.scr)|*.exe;*.scr"
            .ShowOpen
            If Err.Number = cdlCancel Then Exit Sub
            Text1.Text = .FileName
        End With
    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    Yes, use the common dialog control. Click Components on the Project menu and check the control. Put the control on a form and use code simular to this:

    Private Sub cmdBrowse_Click()
    On Error Resume Next
    With CommonDialog1
    .CancelError = True
    .DialogTitle = "Browse"
    .Filter = "Program files|*.exe|Screen savers|*.scr"
    .Flags = cdlOFNHideReadOnly + cdlOFNFileMustExist
    .ShowOpen
    If Err = cdlCancel Then
    Exit Sub
    End If
    Text1 = .filename
    End Sub

    Good luck!

    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com



  4. #4

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    Hey thanks guys but I have one more question. It works great but how can you make it so that it will also show all files?

  5. #5
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    You can create 2 selections in a FileType Combobox.

    Code:
        On Error Resume Next
        
        With CommonDialog1
            .CancelError = True
            .Filter = "Custom Selection (*.exe, *.scr)|*.exe;*.scr|All Files (*.*)|*.*"
            .ShowOpen
            If Err.Number = cdlCancel Then Exit Sub
            Text1.Text = .FileName
        End With
    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    The Filter property is used to choose what files are visible in the dialog box. It has the following syntax:

    CommonDialog1.Filter = "description1 |filter1 |description2 |filter2..."

    Where discription is a string expression describing the file types (i.e All Files) and the filter is a string expression specifying the filename extension (i.e *.*).

    You can have as many filters as you like:

    CommonDialog1.Filter = "Program files|*.exe|Text documents|*.txt|HTML|*.htm;*.html|All files|*.*"

    Good luck!

    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com



  7. #7

    Thread Starter
    Hyperactive Member PITBULLCJR's Avatar
    Join Date
    Nov 1999
    Location
    New York
    Posts
    408

    Post

    Hey Thanks guys. It works great now. I really apretaite (I don't think I spelled that right but who cares)it. Do you guys have anyidea how to change desktop themes or screen savers and mouse pointers and desktop size and stuff like that?

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