?
Solved

Returning an exception caught in one procedure to another

Posted on 2005-03-23
6
Medium Priority
?
251 Views
Last Modified: 2010-04-17
right here we go.....

I have a procedure:
Private Sub DataValidation()
        '=============================================================================
        'This procedure is called to ensure all data is valid
        'If not the user is prompted to amend the invalid data
        '3 procedures are called to check the validity of the data held in the 3
        'data input components on screen
        '=============================================================================
        Try
            TitleValidity()
            RateValidity()
            DescValidity()
        Catch
            MsgBox("validation error")
        End Try
    End Sub

NOW... within the first pro(titlevalidity( ) ) that is called I have a if statement where if a criteria is met then I want to display a prompt and stop the processing so say the 'title' hasnt been entered and I want to stop the validation and let the user makes the amendments.
To do this I am using Exit Sub. However this is only exiting the Titlevalidity( ), it then moves on to RateValidity( ).

I want to stop completely.
I'm assuming that I need to have a try..catch in the validity( ) that catches an exception and then parses it back to the try catch in datavalidation( ), is this right and if so how exactly do I do it im a bit unclear.

If not, what do u recommend?

Any1 save a man in need?
0
Comment
Question by:scm0sml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 13616495
In TitleValidity you do not need a try catch, you could simply "raise" an error which would be caught at the higher level.
0
 

Author Comment

by:scm0sml
ID: 13616523
so raising an error in titlevalidity say throw e etc would be automatically passed down?
0
 
LVL 16

Accepted Solution

by:
JohnBPrice earned 1000 total points
ID: 13616551
Yes, like so

   Private Sub TitleValidity()

        Err.Raise(513)
        'or         Throw New System.Exception("An exception has occurred.")
    End Sub
    Private Sub RateValidity()
        MsgBox("In RateValidity")
    End Sub
    Private Sub DescValidity()
        MsgBox("In Desc Validity")
    End Sub
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 16

Expert Comment

by:JohnBPrice
ID: 13616562
In my example, the rate & Desc msgboxes never get shown because the exception gets caught first.
0
 

Author Comment

by:scm0sml
ID: 13616601
easy when u know how!!

couple of easy points for you, cheers!!
0
 
LVL 16

Expert Comment

by:JohnBPrice
ID: 13616614
Thanks....
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Simple Linear Regression
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question