See how to use the try-catch keywords to handle exceptions.
- [Programmer] I'll add some try catch protection … in this first event handler by typing in the word … try and then pressing the enter key. … And then I'll delete this bit of code here, … and leave it at the simple try, catch, end try. … So, then I'll take this code and move it into the try block. … So, what we see here is the try and the end try … with a single catch, and this says, … run the code in here, and if there's any exceptions … doesn't matter what type of exception, … run the code in this catch block. … In other words, catch any and all exceptions. … Now, I'm leaving that blank for the moment. … Clicking on this button, you can see … that something's happening because … this number is incrementing, but we're not aware … from the user's perspective that there's … this FileNotFoundException happening. … The exception is caught in that empty catch block, … we're not doing anything in the catch block. … Essentially, we are ignoring any and all exceptions. … This appears to be a nice solution, …
Author
Released
10/18/2019- Visual Basic syntax
- Using .NET classes in your application
- Declaring variables and data types
- Working with numbers and dates
- Using strings
- Repeating blocks of code with loops
- Evaluating conditions with if, then, and else
- Debugging and handling exceptions
- Working with lists
Skill Level Beginner
Duration
Views
Related Courses
-
Visual Studio 2019 Essential Training
with Walt Ritscher4h 24m Intermediate -
Developing with Visual Studio Code
with Jesse Liberty57m 23s Beginner -
Visual Studio for Mac
with Bruce Van Horn4h 10m Beginner -
Learning Visual Studio Code
with Reynald Adolphe1h 20m Beginner
-
Introduction
-
What you should know1m 38s
-
Setup packages4m 14s
-
1. Build Your First Simple Applications
-
Work with the Console class2m 27s
-
2. Create Projects in Visual Studio
-
Edit the code3m 51s
-
Compile the project code1m 58s
-
3. Work with Multiple Projects
-
Choose a startup project3m 8s
-
Add click event handler code3m 13s
-
4. Setting Up Your Environment
-
Work with Git branches2m 39s
-
5. Program Flow
-
Understand default code flow5m 13s
-
Create a program loop5m 19s
-
-
6. The Visual Basic Ecosystem
-
.NET and .NET core4m 17s
-
7. Variables and Constants
-
Declare a variable6m 30s
-
Understand variable scope5m 42s
-
Convert numeric values5m 43s
-
Work with strings7m 11s
-
Work with dates and times9m 21s
-
8. Refactor Your Code into Functions and Subs
-
Add procedures to module3m 35s
-
Add procedures to class1m 50s
-
Add code to functions2m 22s
-
9. Debugging Your Code
-
Add breakpoints to code4m 10s
-
Step through code4m 2s
-
Use the Watch windows4m 24s
-
-
10. Control Flow: Branch Statements
-
If and Else5m 16s
-
Select Case3m 30s
-
11. Control Flow: Loop Statements
-
Solution: Pentagonal numbers2m 44s
-
12. Work with Lists
-
Create new collections4m 49s
-
Iterate over list5m 39s
-
Interesting list properties4m 42s
-
Work with extension methods2m 40s
-
Use LINQ with lists5m 14s
-
13. Error Handling
-
Logging exceptions4m 58s
-
Continuing Your Journey
-
Next steps55s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Use try-catch for exception handling