|
-
Dec 14th, 1999, 09:24 PM
#1
Thread Starter
Hyperactive Member
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.
-
Dec 14th, 1999, 09:30 PM
#2
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
-
Dec 14th, 1999, 09:30 PM
#3
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
-
Dec 14th, 1999, 09:37 PM
#4
Thread Starter
Hyperactive Member
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?
-
Dec 14th, 1999, 09:46 PM
#5
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
-
Dec 14th, 1999, 09:55 PM
#6
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
-
Dec 15th, 1999, 01:07 AM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|