Results 1 to 3 of 3

Thread: How do I exit a case statement?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78

    Question How do I exit a case statement?

    Hi,
    How do I get out of a case statement after a function has found a problem. What I mean is:

    Code:

    Select case index

    Case 0

    functionperformed
    if x = y then
    form.show vbmodal
    endif

    Case 1

    unload me

    end select

    where functionperformed = the function that is performed

    Now. What I want to do is exit the case statement after the function has been completed. In other words, how do i exit out of Case 0 when the function has created a problem and it needs to exit from the case index and revert back to the form originally loaded? Any help is appreciated and thanks in advance.

    Mike

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    No way to exit a case
    solution 1. use a goto, to a label after the end select
    solution 2. use an if then inside the case and put the rest in else.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Lively Member
    Join Date
    Apr 2000
    Location
    Rafaela (Argentine)
    Posts
    107
    Let the function return a boolean value. If the function finds a problem, return False; else return True. Then, you can use it as:

    Code:
    Select Case index 
       Case 0 
          If functionperformed Then
             If x = y Then
                Form.Show vbModal 
             End If 
          End If
       Case 1 
          Unload Me 
    End Select
    Hope it works!

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