On Error Goto Hell Vb
your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 4 of 4 Thread: On Error Goto Hell Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Oct 13th, 2001,09:00 PM #1 747 Guest On Error Goto Hell On Error GoTo ErrHandler I have this under every command button on my form, but I think there is another way of doing this please advise Reply With Quote Oct 13th, 2001,09:02 PM #2 agent View Profile View Forum Posts Fanatic Member Join Date Jun 1999 Location California, USA Posts 662 nope. not in any version of vb before vb.net. Reply With Quote Oct 13th, 2001,09:06 PM #3 beachbum View Profile View Forum Posts Visit Homepage PowerPoster Join Date Jul 2001 Location Wollongong, NSW, Australia Posts 2,274 If nothing critical is happening in ur routines u can just use On Error Resume Next. Saves adding the handler to each sub. Regards Stuart Stuart Laidlaw Brightspark Financial Software http://www.gstsmartbook.com Reply With Quote Oct 13th, 2001,09:21 PM #4 DaoK Guest I never use On Error Resume Next until I have solved all problem. WHen I see than I am ready to make it EXE than I put it in all function and command to be sure to don't have any error if user try it on their PC. Reply With Quote Quick Navigation Visual Basic 6 and Earlier Top Site Areas Settings Private Messages Subscriptions Who's Online Search Forums Forums Home Forums Visual Basic Visual Basic .NET VB.net CodeBank Visual Basic 6 and Earlier CodeBank - Visual Basic 6 and earlier Modern Windows Experience (Metro) Office Development Mobile Development ASP, VB Script Database Development Reporting API Games and Graphics Programming Game Demos COM and ActiveX Network Programming Visual Basic FAQs Slow Chat with the Microsoft Visual Basic team .NET ASP.NET Visual Basic .NET MVC .Net C# WPF, WCF, WF Silverlight .NET Architecture and Design General General Developer Forum IoT, IoE, and Maker Forum Testers and Testing Application Testing Application Deployment Linux Development General PC VBForums Coding Co
General > on error goto hell Thread Tools Display Modes #1 03-03-2003, 04:41 PM jlbryant Contributor Join Date: Jan 2003 Posts: 650 on error goto i have a code that i have an on error goto error1: on , and when it does goto the error1: and reads the code under that if i have another error how do i tell it to go to another error # like error2: Last edited by loquin; 03-03-2003 at 05:17 PM. Reason: some may find dubject objectionable jlbryant View Public Profile Find all posts by jlbryant #2 03-03-2003, 04:46 PM Volte Ultimate Contributor Retired Leader* Guru * Join Date: Aug 2001 Posts: 5,344 In the error handler, you just check the error number. For example, Code: http://www.vbforums.com/showthread.php?110745-On-Error-Goto-Hell Public Sub SomeSub() On Error Goto ErrHandler Dim a As Integer a = 7/0 '<-- Division by zero a = 32770 '<-- Overflow Exit Sub ErrHandler: Select Case Err.Number Case 6 'Overflow Msgbox "The number was too big" Case 11 'Division by zero MsgBox "You can't divide by zero!" Case Else MsgBox "Unknown error: " & Err.Description End Select Resume Next End Sub You can get a list of error numbers from the MSDN. Volte View Public Profile Find all posts by Volte http://www.xtremevbtalk.com/general/64416-error-goto-hell.html « Previous Thread | Next Thread » Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) Thread Tools Show Printable Version Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News & Notifications Announcements .Net News & Articles Visual Basic .NET (2002-2015), including Express editions) .NET Knowledge Base Tutors' Corner Code Library ASP.Net .NET Communications .NET Game Programming Managed DirectX .NET Office Automation .NET File I/O and Registry .NET Database and Reporting .NET Interface and Graphics .NET Installation / Documentation .NET General Xtreme .NET Talk Legacy Visual Basic (VB 4/5/6) Knowledge Base Tutors' Corner Code Library Communications Game Programming DirectX VBA / Office Integration Excel Word, PowerPoint, Outlook, and Other Office Products API File I/O and Registry Database and Reporting Interface an
Database Guide User login Username: * Password: * Request new password Home › Tutorials GoTo and GoSub in Visual Basic 6 Level: The VB6 GoTo Statement The GoTo vb6 statement can be used to branch to statements within a Sub or Function procedure. http://www.vb6.us/tutorials/goto-and-gosub-visual-basic-6 We have all heard the lectures on the "evils" of using vb6 GoTo statements, so http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=36522&lngWId=1 I'm not going to rehash all that here. In general, use of modern programming constructs such as the ones previously presented (Do/Loop, If/Then/Else, Select Case, etc.) virtually eliminate the need to use GoTos. You'll find that the only time that the use of GoTo is required is when setting up error-handling code (error-handling is discussed in a later topic). The rules for on error using GoTo are as follows: · The destination of a vb6 GoTo statement must be a line label or line number that resides within the same Sub or Function procedure as the statement that issues the GoTo (i.e., you cannot "go to" a line in a Sub or Function other than the one you are currently in). · The name of the line label follows the same rules as that for naming a variable. The line label must on error goto begin in the first column of the line and must be followed by a colon(:). · If a line number is used, it must begin in the first column of the line. Following is a version of the factorial program presented earlier that uses GoTos instead of the For/Next loop for looping : Private Sub cmdTryIt_Click() Dim lngFactorial As Long Dim intInputNbr As Integer Dim intLoopCtr As Integer intInputNbr = Val(InputBox("Enter a number:", "GoTo Demo")) lngFactorial = 1 intLoopCtr = 1 Loop_Start: If intLoopCtr > intInputNbr Then GoTo 10 lngFactorial = lngFactorial * intLoopCtr intLoopCtr = intLoopCtr + 1 GoTo Loop_Start 10 ' End of loop Print CStr(intInputNbr); "! = "; lngFactorial End Sub Download the VB project code for the example above here. The GoSub Statement In earlier versions of BASIC, the only way you could make your programs modular was to break your program up into "subroutines" and use GoSub to execute that subroutine and return back to the calling statement. GoSub was included in VB to maintain backward compatibility; it is not a particularly "bad" construct to use, but its use is generally discouraged – it is recommended that Sub and Function procedures be used instead. The rules for using GoSub are as follows: · The destination of a GoSub statement must be a line label or line n
visit:
Active Server Pages: Active Server Pages source code and tutorials. C / C++: C/C++ source code and tutorials. ColdFusion: ColdFusion source code and tutorials. Delphi: Delphi source code and tutorials. .Net: .net source code and tutorials. Homepage: source code and tutorials. Java: Java source code and tutorials. HTML 5/JavaScript: HTML5/JavaScript source code and tutorials. Perl: Perl source code and tutorials. PHP: PHP source code and tutorials. SQL: SQL source code and tutorials. VB classic: Visual Basic source code and tutorials. Search: Choose language … .Net ASP / VbScript C / C++ Cold Fusion Delphi Java HTML 5 / Javascript Perl PHP SQL Visual Basic Search Newest postings for all languages. MDB ADO SQL RESET COUNTER By Quake on 10/23 Language: vb VB Batch Compile 23-Oct-2016 By Kenaso on 10/23 Language: vb (Screen Shot) ZipDater 23-Oct-2016 By Kenaso on 10/23 Language: vb (Screen Shot) Tiger3 hash demo 23-Oct-2016 By Kenaso on 10/23 Language: vb (Screen Shot) Disk Data Wipe 23-Oct-2016 By Kenaso on 10/23 Language: vb (Screen Shot) MDB ADO DateValue By Quake on 10/23 Language: vb (Screen Shot) CMultiBits & CLongBits By Robert Dee on 10/23 Language: vb Start Screensaver 22-Oct-2016 By Kenaso on 10/22 Language: vb Test Random Values 22-Oct-2016 By Kenaso on 10/22 Language: vb (Screen Shot) Test Passwords 22-Oct-2016 By Kenaso on 10/22 Language: vb (Screen Shot) Sorting Demo 22-Oct-2016 By Kenaso on 10/22 Language: vb (Screen Shot) kiMisc Demo 22-Oct-2016 By Kenaso on 10/22 Language: vb (Screen Shot) MDB FolderPath Treeview By Quake on 10/21 Language: vb (Screen Shot) Reboot PC 21-Oct-2016 By Kenaso on 10/21 Language: vb (Screen Shot) kiPrng Demo 21-Oct-2016 By Kenaso on 10/21 Language: vb (Screen Shot) Password/Phrase Creation 21-Oct-2016 By Kenaso on 10/21 Language: vb (Screen Shot) kiSHA Demo 21-Oct-2016 By Kenaso on 10/21 Language: vb (Screen Shot) kiHash Demo 20-Oct-2016 By Kenaso on 10/20 Language: vb (Screen Shot) kiCrypt cipher demo 20-Oct-2016 By Kenaso on 10/20 Language: vb (Screen Shot) graphics-3d-bas ic By jorge flores p. on 10/20 Language: vb (Screen Shot) Defrag Files and Folders 19-Oct-2016 By Kenaso on 10/19 Language: vb (Screen Shot) Count Lines of Code 19-Oct-2016 By Kenaso on 10/19 Language: vb (Screen Shot) Create Big Files 19-Oct-2016 By Kenaso on 10/19 Language: vb (Screen Shot) Build Tables 19-Oct-2016 By Kenaso on 1