Professional Documents
Culture Documents
CC103 5
CC103 5
CC103
Intermediate Programming
Prepared by:
Kairos Jil I. Molina
molinakairos@gmail.com
Lesson
Select Case
8 Statement
What is Select Case in VB.Net?
Select Case is a conditional statement, that helps you test a variable for equality against
a set of values. Each value is referred to as a case, and a variable that is being switched
on should be checked for all the select cases.
The Select Case statement provides you with an easy way of testing for the contents of
a variable. However, it is only suitable for use when a variable in question has only a
limited number of options.
Sample Code:
Output:
Sample Code:
Sample Code:
The value of the variable name will be used for performing comparisons with the various Case
statements to find a match. The ToLower() function will ensure that any name the user types is
first converted into lowercase before the evaluation of Case statements. This means that if the
user types Rizal, it will be immediately converted to rizal, then the evaluation of the Case
statements is done.
Summary
The Select Case statement provided by VB.NET helps you evaluate a value against a
set of values through matching.
It is only suitable if the possible values of the variable in question is known to be limited.
The Select Case statement is case sensitive.
You can use the ToLower() and the ToUpper() functions to convert strings into
lowercase and uppercase respectively.
Reference:
https://www.guru99.com/vb-net-select-case.html
Lesson
Exception Handling
9 in VB.Net
What is an Exception in VB.Net?
An Exception in VB.Net refers to a problem that arises during program execution. It is
brought about by an unexpected circumstance. A good example is when you are
performing a division operation, and then you divide by zero (0). An exception will be
raised.
The Try/Catch block should surround the code that may raise an exception. This code is
known as a protected code. You can use multiple catch statements when you need to
catch various types of exceptions.
Sample Code:
https://www.guru99.com/try-catch-finally-vb-net.html