The If Statement
The If statements is one of the most common Visual Basic statements. It allows you to execute one or more statements only when a specific condition is met. This condition is a Boolean expression that will evaluate to True or False. Let's look at an example:
Sub Main() Console.Out.WriteLine("Enter a value for i and press <ENTER>: ") Dim i As Integer i = CInt(Console.In.ReadLine()) Console.Out.WriteLine("Enter a value for j and press <ENTER>: ") Dim j As Integer j = CInt(Console.In.ReadLine()) If i < j Then Console.Out.WriteLine("i is less than j") End If Console.Out.WriteLine("Press the <Enter> key to end the program") Console.In.ReadLine() End Sub
These example declare two Integer variables i and j and gets some values for ...
Get Visual Basic® .NET by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.