On Error Exit Sub Vbscript
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn vbscript quit more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Vbscript Quit Script
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, end vbscript execution helping each other. Join them; it only takes a minute: Sign up What is the code to exit/ stop VBscript from running in the event of a condition not being met? up vote 2 down vote favorite vbscript exit function return value 1 I have looked on Google and the answer is not there! First things first. WScript.Quit DOES NOT WORK! I have no idea what "WScript" is but it clearly has nothing to do with client side scripting for a web page. I have seen this "WScript" thing somewhere before and it just produces errors (maybe obsolete or something) so please do not suggest it... Anyway... all I wish to do is completely stop the script in
Vbscript On Error Goto 0
the event of a condition not being met. Obviously I don't want "Exit Sub" because the code would then carry on running if that sub is embedded! I am aware of the "stop" command but I am under the impression that it is only used for debugging. Hopefully a very simple question. UPDATE and Conclusion: Before I close this subject I will just expand a little on what I was trying to do... I had a number of main subs that were being started by a button click. In order to make it so that I did not have to edit each individual sub I embedded a universal sub within each one that did a preliminary check. Part of that preliminary check was to stop the program in the case of an incorrect user input. If an error was detected I wanted to halt all progress from that point on. An "exit sub" would obviously just skip the rest of that preliminary sub and the main sub would carry on executing. In the end it was just a case of writing in an error flag (that is checked in the main subs) or incorporating the error condition operation in each main procedure. In that way you exit the main sub and the problem is solved. It was not laziness - I just wanted to reduce th
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums wscript.quit exit code Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired wscript.quit not working content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1
Vbscript Exit Sub
second. VBScript VBScript Language Reference Statements (VBScript) Statements (VBScript) Exit Statement Exit Statement Exit Statement Call Statement Class Statement (VBScript) Const Statement (VBScript) Dim Statement Do...Loop Statement Erase http://stackoverflow.com/questions/13503840/what-is-the-code-to-exit-stop-vbscript-from-running-in-the-event-of-a-condition Statement Execute Statement ExecuteGlobal Statement Exit Statement For Each...Next Statement For...Next Statement Function Statement (VBScript) If...Then...Else Statement On Error Statement Option Explicit Statement Private Statement Property Get Statement Property Let Statement Property Set Statement Public Statement Randomize Statement ReDim Statement Rem Statement Select Case Statement Set Statement Stop Statement Sub Statement While...Wend Statement With Statement https://msdn.microsoft.com/en-us/library/t234253x(v=vs.84).aspx (VBScript) TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Exit Statement Exits a block of Do...Loop, For...Next, Function, or Sub code. Syntax Copy Exit Do Exit For Exit Function Exit Property Exit Sub RemarksThe Exit statement syntax has these forms:StatementDescriptionExit DoProvides a way to exit a Do...Loop statement. It can be used only inside a Do...Loop statement. Exit Do transfers control to the statement following the Loop statement. When used within nested Do...Loop statements, Exit Do transfers control to the loop that is one nested level above the loop where it occurs.Exit ForProvides a way to exit a For loop. It can be used only in a For...Next or For Each...Next loop. Exit For transfers control to the statement following the Next statement. When used within nested For loops, Exit For exits the current loop.Exit FunctionImmediately exits the Function procedure in w
Reward points : 0 Joined: 5/7/2007 Status: offline VBS and Exit Sub Thursday, May 10, 2007 9:19 AM (permalink) 0 I have a script that - if a variable comes back NULL then I want to exit the http://www.visualbasicscript.com/VBS-and-Exit-Sub-m46967.aspx sub and the script all together. Sample Code: RECEIPTAMT = InputBox("Please enter RECEIPT AMT","RECEIPT AMT","", 5000,7000) If RECEIPTAMT = "" then exit sub else autECLSession.autECLPS.SetText RECEIPTAMT, 12, 15 end if I did some research and from what I could find from Microsoft was the exit sub should work in VBS but I cant seem to get it to work. I get the following error message: Error in the script on error line 82. Invalid "exit" statement Would you like to edit the script? Programing in PCOMM (Terminal Emulator) IBM version 4.2 Thank you Carl Osburn Carl Osburn Business Process Improvement Vertex Outsourcing cosburn@nisource.com #1 dm_4ever Total Posts : 3712 Scores: 93 Reward points : 0 Joined: 6/29/2006Location: Orange County, California Status: offline RE: VBS and Exit Sub Thursday, May 10, 2007 9:29 AM (permalink) 0 Exit Sub takes you out of a Sub Sub Test() on error exit if... exit sub ' stop the execution of anything after this point in the sub, but the rest of the script continues end if code.... end Sub If you want the script to terminate completely you would use WScript.Quit dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm #2 mcds99 Total Posts : 519 Scores: 4 Reward points : 0 Joined: 2/28/2006 Status: offline RE: VBS and Exit Sub Thursday, May 10, 2007 2:59 PM (permalink) 0 This may be a little goofy but it works. Sub test do some stuff if x <> null value then do this stuff else call quitscript end if end sub sub quitscript files.close wscript.quit end sub Sam Keep it Simple Make it Fun KiSMiF #3 Online Bookmarks Sharing: Jump to: Jump to - - - - - - - - - - [Welcome] - - - - Forum Rules - - - - New Member Area/Introduction [Scripting] - - - - WSH & Client Side VBScript - - - - WSH & Client Side VBScript Tutorial - - - - Post a VBScript - - - - Windows PowerShell - - - - ASP - - - - ASP.NET [General Forum] - - - - Off-Topic Lounge - - - - Other Programming/Scripting Languages -