-
Jul 20th, 2014, 10:46 PM
#1
Thread Starter
Lively Member
Please Help VB6
Hello All,
Code:
Private Sub Command1_Click()
On Error GoTo ERROR_HANDLER
MsgBox "Hello"
ERROR_HANDLER:
MsgBox Err.Description, vbCritical
End Sub
This Code is correct ??
Thanks
-
Jul 20th, 2014, 11:11 PM
#2
Re: Please Help VB6
You need an Exit Sub after MsgBox "Hello". Really no need for error handling for this but anyway that's what you need to have else control falls into error handler routine.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Jul 21st, 2014, 12:12 AM
#3
Re: Please Help VB6
Just to be clear you need an Exit Sub just before the Error_Handler: label so if there were more lines of code after msgbox the Exit statement would be after those lines as well.
Code:
Private Sub Command1_Click()
On Error GoTo ERROR_HANDLER
MsgBox "Hello"
'
'
' possibly many more lines of code
'
'
Exit Sub ' this allows the sub to exit if no error has occurred and prevents the code in the error handler portion from executing
ERROR_HANDLER:
MsgBox Err.Description, vbCritical
End Sub
-
Jul 21st, 2014, 02:55 AM
#4
Hyperactive Member
Re: Please Help VB6
Yes exit sub is the option.
P.S. why are you using a err handler for a simple msgbox O_o
-
Jul 21st, 2014, 04:07 AM
#5
Re: Please Help VB6
It's a question about a concept.
-
Jul 23rd, 2014, 04:49 AM
#6
Thread Starter
Lively Member
-
Jul 23rd, 2014, 04:51 AM
#7
Thread Starter
Lively Member
Re: Please Help VB6
Mr.HAMZA
Thanks
I'm showing little model for you..
Mr.Arnoutdv is right...
Thanks Again..
-
Jul 23rd, 2014, 05:59 AM
#8
Hyperactive Member
Re: Please Help VB6
Originally Posted by kamalkumar2023
Mr.HAMZA
Thanks
I'm showing little model for you..
Mr.Arnoutdv is right...
Thanks Again..
Ok bro.
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
|