Results 1 to 15 of 15

Thread: Pop up messages when many programs are executed in VBA PowerPoint

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,895
    Location
    It's a little hard to test with no If's, but do you mean something like this?

    It's preset to False, and if there is an issue, it just exits

    Only if it goes all the way does it return True


    Option Explicit
    
    
    Sub drv()
        Load UserForm1
        UserForm1.Show
        
    End Sub
    
    
    
    
    Function Apple() As Variant
        Apple = False
        
        If Rnd < 0.25 Then Exit Function
        
        Apple = True
        
    End Function
    
    
    Function Orange() As Variant
        Orange = False
        
        If Rnd < 0.5 Then Exit Function
        
        Orange = True
        
    End Function
    
    
    Function Spinach() As Variant
        Spinach = False
        
        If Rnd < 0.95 Then Exit Function
        
        Spinach = True
        
    End Function

    Another way


    Option Explicit
    
    
    Sub drv()
        Load UserForm1
        UserForm1.Show
        
    End Sub
    
    
    
    
    Function Apple() As Variant
       
        Apple = True
        
        On Error GoTo ReturnFalse
        
        If Rnd < 0.25 Then Err.Raise 500, "Apple", "Rotten Apple"
        
        Exit Function
        
    ReturnFalse:
        Apple = False
        
    End Function
    Function Orange() As Variant
       
        Orange = True
        
        On Error GoTo ReturnFalse
        
        If Rnd < 0.5 Then Err.Raise 501, "Orange", "Rotten Orange"
        
        Exit Function
        
    ReturnFalse:
        Orange = False
        
    End Function
    Function Spinach() As Variant
       
        Spinach = True
        
        On Error GoTo ReturnFalse
        
        If Rnd < 0.75 Then Err.Raise 502, "Spinach", "Rotten Spinach"
        
        Exit Function
        
    ReturnFalse:
        Spinach = False
        
    End Function
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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