Results 1 to 9 of 9

Thread: exit sub2 and sub 1 from sub2

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908

    exit sub2 and sub 1 from sub2

    i have sub1 that call sub2.
    if certain condition is meet, i would like to exit sub2 and at the same time exit sub1 (the one which is calling sub 2) in sub2

    how do i do that?
    thank you.
    Last edited by Goh; Mar 22nd, 2004 at 07:13 AM.

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611
    Make it a function returning True or False:
    VB Code:
    1. Private Sub Sub1 ()
    2. Dim blnExit as boolean
    3. 'bla
    4. bla_2
    5. blnExit = Func2(bla)
    6. if blnExit then
    7.     exit sub
    8. endif
    9.  
    10. end sub
    11.  
    12. Private function Func2(strBLA as string) as boolean
    13. if len(strBLA) < 4 then
    14.     func2 = true
    15. endif
    16. 'bla bla
    17. 'text1.text = ucase(strbla)
    18. func2 = False
    19. end function
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    hmmm...thanks!!!!

  4. #4
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611
    Add [RESOLVED] to the topictitle pleazzz
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    is there any other better solution to this problem.....i have lots of 'if then ' in sub2 that is being called?

  6. #6

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2004
    Posts
    908
    how do i raise an error?

  8. #8
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611
    VB Code:
    1. err.raise 666

    Then check in the errorhandler if the errornumber = 666 then you know it is the errer you raised...
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  9. #9
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    VB Code:
    1. Private Sub MySub1()
    2. On Error Goto ErrHandler
    3.    Call MySub2
    4.    Exit Sub
    5. ErrHandler:
    6.    If Err.Number <> vbObjectError Then
    7.       Err.Raise Err.Number, Err.Source, Err.Description
    8.    End if
    9. End Sub
    10.  
    11. Private Sub MySub2()
    12. On Error Goto ErrHandler
    13.    If "Fish" = "Woof" Then
    14.       Err.Raise vbObjectError 'forces code to jump to errhandler
    15.    End If
    16.    Exit Sub
    17. ErrHandler:
    18.    Err.Raise Err.Number, Err.Source, Err.Description
    19. End Sub
    Woka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width