Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 11-17-2022, 02:28 PM
gmaxey gmaxey is offline Proper use of lbl_Exit: Windows 10 Proper use of lbl_Exit: Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Brian,


I do that a lot and I've posted a lot of code here with the lbl_Exit statement.


I use phrase express and when I type sam in a VB code pane, I get:


Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey

lbl_Exit:
Exit Sub
End SUb


When I am reviewing other people's (often to fix), I usually add the lbl_Exit statement as a flag to remind me that I've already looked at that procedure.


Often, and in those cases, it has no functional value and only there as style. Some folks from the old school used to practice never let a procedure run to the End Sub line. Exit first. Why, I don't know but it just became as habit for me.

To make is useful, I would do something like this:

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng as Range
Set oRng = ActiveDocument.range
On Error GoTo Err_Handler
Err.Raise 6
lbl_Exit:
Set oRng = Nothing
Exit Sub
Err_Handler:
Msgbox Err.Number & " " & Err.Description
Resume lbl_Exit
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Proper use of lbl_Exit: Making exceptions to PROPER Chayes Excel Programming 8 06-05-2018 07:19 AM
Proper use of lbl_Exit: Need a proper Office 2010 Flobiwan Office 2 04-23-2017 04:27 AM
Button does not generate proper colors? cloudforgiven Excel 10 12-22-2016 09:57 PM
proper snoforlife Excel Programming 0 01-26-2016 02:16 PM
Proper Text Format sufian,naeem Excel 1 05-05-2014 05:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft