+ Reply to Thread
Results 1 to 5 of 5

Assert vs Stop

  1. #1
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Assert vs Stop

    Is there any advantage to one of these over the other? gbDevelopment will only be True on my computer. It will never be true on a distributed file. And the distributed file will not be compiled into an executable. It won't even be password protected.

    Please Login or Register  to view this content.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Assert vs Stop

    My question would be the stack and cleaning it off. Also, it might be better to branch down to an error routine to see why you got there.

    Read: http://www.fmsinc.com/tpapers/vbacode/Debug.asp section Writing Code for Debugging.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Assert vs Stop

    Hello foxguy,

    As far as VBA is concerned there is no difference between Stop and Debug.Assert in the IDE. When Stop is compiled into an executable program, it behaves like the End statement. It will then close any open files and clear all variables.

    Personally, I like the Stop statement since it is clear what the code is doing. Debug.Assert breaks the code when the condition is False. Some carry over from the days of yore in "C".
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Assert vs Stop

    Leith, I don't think Stop behaves like End at all. Specificably, it does not clear variables, it just halts code excution.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Assert vs Stop

    Hello shg,

    It will if compiled in an executable (.exe). However, that really isn't an issue with VBA.

    See this article: http://msdn.microsoft.com/en-us/libr...8VS.60%29.aspx

    Note: This applies to VS 6.0 and VB.net

    Form the VBA help files:
    The Stop statement suspends execution, but unlike End, it doesn't close any files or clear variables, unless it is in a compiled executable (.exe) file.
    Last edited by Leith Ross; 12-20-2010 at 01:17 AM.

+ 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