+ Reply to Thread
Results 1 to 4 of 4

"ByVal Cancel As MSForms.ReturnBoolean"

  1. #1
    rbyteme
    Guest

    "ByVal Cancel As MSForms.ReturnBoolean"

    Have been unable to find any help on these details, nor any VB programmers
    who can give a definitive answer...

    the subject line code is default for many event subs in VBA. exactly what is
    setting the Cancel var?? to put it another way, when or what would cause the
    var Cancel to be True? Have tested in a huge # of scenarios involving closing
    and cancelling forms and controls, and have yet to see Cancel = anything
    besides False.

    also...ReturnBoolean is obviously not same as Boolean. can it be anything
    else besides True or False? would it be useful anywhere else?

    thanks for any replies

  2. #2
    Rob Bovey
    Guest

    Re: "ByVal Cancel As MSForms.ReturnBoolean"


    MSForms.ReturnBoolean is a class exposed by the MSForms type library.
    This class has only one property, the default Value property. The purpose of
    an MSForms.ReturnBoolean variable is not to pass any information into an
    event it's to allow you to pass information back to VBA telling it whether
    or not you want to cancel the current operation. Setting the Cancel = True
    (the equivalent of Cancel.Value = True) means you do want to cancel the
    operation. Setting Cancel = False or leaving it with its default value of
    False means you don't want to cancel the operation.

    --
    Rob Bovey, Excel MVP
    Application Professionals
    http://www.appspro.com/

    * Take your Excel development skills to the next level.
    * Professional Excel Development
    http://www.appspro.com/Books/Books.htm

    "rbyteme" <rbyteme@discussions.microsoft.com> wrote in message
    news:F25FB8BD-63EC-4973-992C-5A34CDCE4F74@microsoft.com...
    > Have been unable to find any help on these details, nor any VB programmers
    > who can give a definitive answer...
    >
    > the subject line code is default for many event subs in VBA. exactly what
    > is
    > setting the Cancel var?? to put it another way, when or what would cause
    > the
    > var Cancel to be True? Have tested in a huge # of scenarios involving
    > closing
    > and cancelling forms and controls, and have yet to see Cancel = anything
    > besides False.
    >
    > also...ReturnBoolean is obviously not same as Boolean. can it be anything
    > else besides True or False? would it be useful anywhere else?
    >
    > thanks for any replies




  3. #3
    Tom Ogilvy
    Guest

    Re: "ByVal Cancel As MSForms.ReturnBoolean"

    Your code would be what sets the cancel to true. You will find this in
    events usually starting with Before. for example, in the BeforeSave event
    you might run code to check if all required cells are filled out. If they
    are not, you might have your code do

    Cancel = True

    and then the workbook won't be saved (the action which triggered the event
    to run is cancelled).

    So it will always be passed in as False. You routine has the option of
    setting it to true if you want to cancel the normal action which would be
    performed in response to the action that triggered the event.

    --
    Regards,
    Tom Ogilvy

    "rbyteme" <rbyteme@discussions.microsoft.com> wrote in message
    news:F25FB8BD-63EC-4973-992C-5A34CDCE4F74@microsoft.com...
    > Have been unable to find any help on these details, nor any VB programmers
    > who can give a definitive answer...
    >
    > the subject line code is default for many event subs in VBA. exactly what

    is
    > setting the Cancel var?? to put it another way, when or what would cause

    the
    > var Cancel to be True? Have tested in a huge # of scenarios involving

    closing
    > and cancelling forms and controls, and have yet to see Cancel = anything
    > besides False.
    >
    > also...ReturnBoolean is obviously not same as Boolean. can it be anything
    > else besides True or False? would it be useful anywhere else?
    >
    > thanks for any replies




  4. #4
    rbyteme
    Guest

    Re: "ByVal Cancel As MSForms.ReturnBoolean"

    AHA INSIGHT. Thank you very much, Rob and Tom.



    "Rob Bovey" wrote:

    >
    > MSForms.ReturnBoolean is a class exposed by the MSForms type library.
    > This class has only one property, the default Value property. The purpose of
    > an MSForms.ReturnBoolean variable is not to pass any information into an
    > event it's to allow you to pass information back to VBA telling it whether
    > or not you want to cancel the current operation. Setting the Cancel = True
    > (the equivalent of Cancel.Value = True) means you do want to cancel the
    > operation. Setting Cancel = False or leaving it with its default value of
    > False means you don't want to cancel the operation.
    >
    > --
    > Rob Bovey, Excel MVP
    > Application Professionals
    > http://www.appspro.com/
    >
    > * Take your Excel development skills to the next level.
    > * Professional Excel Development
    > http://www.appspro.com/Books/Books.htm
    >
    > "rbyteme" <rbyteme@discussions.microsoft.com> wrote in message
    > news:F25FB8BD-63EC-4973-992C-5A34CDCE4F74@microsoft.com...
    > > Have been unable to find any help on these details, nor any VB programmers
    > > who can give a definitive answer...
    > >
    > > the subject line code is default for many event subs in VBA. exactly what
    > > is
    > > setting the Cancel var?? to put it another way, when or what would cause
    > > the
    > > var Cancel to be True? Have tested in a huge # of scenarios involving
    > > closing
    > > and cancelling forms and controls, and have yet to see Cancel = anything
    > > besides False.
    > >
    > > also...ReturnBoolean is obviously not same as Boolean. can it be anything
    > > else besides True or False? would it be useful anywhere else?
    > >
    > > thanks for any replies

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1