-
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.
-
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
-
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
-
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?
-
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
-
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
-
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?