Click to See Complete Forum and Search --> : Browse
PITBULLCJR
Dec 14th, 1999, 08:24 PM
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.
Serge
Dec 14th, 1999, 08:30 PM
Add a Microsoft Common Dialog Control to your form and use this 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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Joacim Andersson
Dec 14th, 1999, 08:30 PM
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
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)
PITBULLCJR
Dec 14th, 1999, 08:37 PM
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?
Serge
Dec 14th, 1999, 08:46 PM
You can create 2 selections in a FileType Combobox.
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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Joacim Andersson
Dec 14th, 1999, 08:55 PM
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
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)
PITBULLCJR
Dec 15th, 1999, 12:07 AM
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?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.