|
-
Nov 9th, 2000, 02:49 AM
#1
Thread Starter
Hyperactive Member
Morning Everyone ,
How can I tell when a user selects a file in a common dialog box . I have a CDB to let the user browsw to a file , I want to know when he has selected it and pressed "open"
Thnks
[]P
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Nov 9th, 2000, 03:21 AM
#2
Your code will stop at
Code:
CommonDialog1.ShowOpen
until the user clicks Open or Cancel. So:
Code:
CommonDialog1.ShowOpen
Msgbox "selected"
The message box will come up after the user has click Open or Cancel.
Sunny
-
Nov 9th, 2000, 10:22 AM
#3
Frenzied Member
More data.
Here is some more about Common Dialogue box. Following is copied from code which worked.
Code:
Private Sub mnuFileOpen_Click()
'cdlOFNCreatePrompt &H2000 File should not exist'
'cdlOFNFileMustExist &H1000'
'cdlOFNOverwritePrompt &H2'
'cdlOFNPathMustExist &H800'
'cdlOFNLongNames &H200000'
dlogCommon.Flags = &H201800 'Long Names; File & Path must exist'
dlogCommon.CancelError = True
dlogCommon.DialogTitle = "Gravity: Read File"
dlogCommon.FileName = GrvtyFile
dlogCommon.InitDir = GrvtyDirectory
dlogCommon.Filter = "Gravity Files(*.grv)|*.grv|All Files(*.*)|*.*"
On Error GoTo BadOpen
dlogCommon.ShowOpen
'Fall through here if User does not cancel/close'
GrvtyFileName = dlogCommon.FileName
Call BodyGettor(GrvtyFileName)
cboxBodyName.SetFocus
Exit Sub
BadOpen:
'Ignore: User changed him mind about opening file'
cboxBodyName.SetFocus
End Sub
Some of the above is specific to my application, but it should give you some ideas.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Nov 9th, 2000, 10:26 AM
#4
New Member
You can also just put
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
if FileName = "" then exit sub
If the user clicks cancel, the subroutine won't continue.
-
Nov 9th, 2000, 10:54 AM
#5
Originally posted by olaf_001
You can also just put
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
if FileName = "" then exit sub
If the user clicks cancel, the subroutine won't continue.
You must have CancelError set to true and error handling as well so that if the user presses cancel, you won't get any error.
'On Error Resume Next
'CommonDialog.CancelError = True
-
Nov 9th, 2000, 01:59 PM
#6
Thread Starter
Hyperactive Member
Thnks Guys , I was trying to figure out WHEN I could get the the stats of the File selected like size and type . Now I know 
Thanks again ,
[]P
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
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
|