Results 1 to 4 of 4

Thread: [RESOLVED] [VB6] Exit Sub on CommonDialog Cancel

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Location
    White Oak, PA
    Posts
    25

    Resolved [RESOLVED] [VB6] Exit Sub on CommonDialog Cancel

    Hello everyone! I am using Microsoft Visual Basic 6. How do I exit the sub when the "Cancel" button is clicked in the CommonDialog? Thank you!
    Last edited by Shadowz O Death; Aug 23rd, 2008 at 01:51 PM.

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Exit Sub on CommonDialog Cancel

    Code doc(a member's username with a black bear as the avatar) has some code for using common dialog control. He had posted it in some of the previous threads. Search the forum for his code...

    Good day, pal...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Exit Sub on CommonDialog Cancel

    You have to set CancelError to True:
    Code:
    Private Sub Command1_Click()
    
    On Error GoTo ErrHandler
    
        With CommonDialog1
            .CancelError = True '<<< this is the key
            .ShowOpen
            '...
        End With
        
        Exit Sub
    
    ErrHandler:
    
        Err.Clear
        Exit Sub
    
    End Sub

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Location
    White Oak, PA
    Posts
    25

    Re: Exit Sub on CommonDialog Cancel

    Quote Originally Posted by RhinoBull
    You have to set CancelError to True:
    Code:
    Private Sub Command1_Click()
    
    On Error GoTo ErrHandler
    
        With CommonDialog1
            .CancelError = True '<<< this is the key
            .ShowOpen
            '...
        End With
        
        Exit Sub
    
    ErrHandler:
    
        Err.Clear
        Exit Sub
    
    End Sub
    Thank you!

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