Noob Question but...
What Code would i use in vb6 to make it so when a user clicks File->open this pops up
How to Open a file
Ok i found out how to get it to work with this code
But how do i make it so there isnt an error when pressing cancle??
Code: Select all
cdlCommon.CancelError = True
cdlCommon.Flags = cdlOFNHideReadOnly ' Hides read only files
cdlCommon.Filter = "All Files (*.*)|*.*|Halo 2 Map File" & _
"(*.map)|*.map|"
' Specify default filter
cdlCommon.FilterIndex = 2
cdlCommon.ShowOpen
-
- Posts: 325
- Joined: Mon Mar 22, 2004 3:59 pm
- Location: Everywhere but nowhere
- Contact:
--GO TO BOTTOM OF THIS POST BEFORE READING--
If you're having trouble you can review Uber-banana's tutorial on this.
If you want to null out any errors you still may be having...
This is how to set specific tasks to perform if the process comes across any erros. At the beginning of the 'Private Sub' put the statement: 'On Error GoTo errorhandler'
errhandler is just a random name i decided to choose for the 'Goto' label. Your code should look relatively like this now:
After that you can put the code for the open dialog and whatever else you want. At the end of that code place the line 'Exit Sub'. This will quit the process and ignore everything beyond that line. This means if no errors occurr while the open file dialog is open then it will ignore this next line:
This means that when an error is run upon and it goes to the line defined as 'errorhandler' it will commit the action of 'Exit Sub'.
This is what your final code should look like:
Anyways, if you meant an error that Visual Basic was giving you then I just wasted my time. Whatever, you actually probably are, add this right after '.Flags'
I want to kill myself...
If you're having trouble you can review Uber-banana's tutorial on this.
If you want to null out any errors you still may be having...
This is how to set specific tasks to perform if the process comes across any erros. At the beginning of the 'Private Sub' put the statement: 'On Error GoTo errorhandler'
errhandler is just a random name i decided to choose for the 'Goto' label. Your code should look relatively like this now:
Code: Select all
Private Sub cmd1_Click()
On Error GoTo errorhandler
Code: Select all
errorhandler:
Exit Sub
This is what your final code should look like:
Code: Select all
Private Sub cmd1_Click()
On Error GoTo errorhandler
' (Your code here)
Exit Sub
errorhandler:
Exit Sub
End Sub
Anyways, if you meant an error that Visual Basic was giving you then I just wasted my time. Whatever, you actually probably are, add this right after '.Flags'
Code: Select all
cdlCommon.CancelError = False