In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
How to deal with errors in VB language and how to debug goto statements and on error statements in code? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Error handling and code debugging
First, error handling
If the program reports an error, if it is in the software development interface, the code will stop to the corresponding error line, and sometimes it is not accurate
On error resume next
Meaning: when an error occurs, let the program continue to run the next line of code, ignoring the error report
Goto statement
Goto tag name meaning: directly causes the code to jump to the corresponding tag line code
How to define the label?
Label name:
The actually executed code
Note: the code where the label is defined will still be executed by the program
In fact, we can use the idea of goto to construct a loop statement, but it is not recommended to use goto to construct a loop, nor is it recommended to use goto too much, because it will make the readability of the program worse
Use Goto in conjunction with error handling
On error goto err1
Err1:
Processing statement
Note: goto tags can only appear inside function or sub
Second, code debugging
Debugging steps
1. The breaking point. The program will be paused when it is powered off.
2, use the f8 button to enter the program code, you can enter function or sub to debug. Shfit+f8 refers to the execution of one line of code. Ctrl+shift+f8 means that you can jump directly out of function or sub
3. When debugging, you can see the value of the variable by placing the mouse over the variable
4. You can also see the results of the adjusted variables in the output console through the Debug.Print method.
Related codes:
Private Sub Command1_Click ()
On Error Resume Next
Print 1 / 0
Print "Liu Jinyu"
End Sub
Private Sub Command2_Click ()
GoTo web2
Print "Liu Jinyu"
Web:Print "ljy.kim"
Web2:Print "selidev.com"
GoTo web
End Sub
Private Sub Command3_Click ()
On Error GoTo err1Call cal (1,3) Print "Liu Jinyu" Print "Liu Jinyu programming"
Err1:MsgBox "made a mistake"
End Sub
Function cal (an As Integer, b As Integer)
Debug.Print (a + b)
Print a + b
End Function
This is the answer to the question about how to handle errors in VB language and how to debug goto statements and on error statements. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.