Related Literature

Submitted by: Submitted by

Views: 10

Words: 657

Pages: 3

Category: Literature

Date Submitted: 01/10/2016 11:53 PM

Report This Essay

If Else

Syntax:

If condition Then

code

Else

other code

End If

Comment out the other If Statement (CTRL+K+C) and copy the following code:

Dim username As String

Dim password As Integer

username = Nothing

password = Nothing

Console.WriteLine("Enter Your UserName")

username = Console.ReadLine()

Console.WriteLine("Enter Your Password")

password = Console.ReadLine()

If username = "Asim" And password = 243 Then

Console.WriteLine("Welcome Asim!")

Else

Console.WriteLine("Access is denied")

End If

Console.ReadLine()

This is similar to the above If Statement. You have two variables (string/integer) which we use to store the values the user enters when prompted. Then we compare those values to the values in our If Statement. So if username = "Asim" AND password = 243, then "Welcome Asim" is displayed; otherwise "Access Denied" is displayed. You are also using the logical operator And which will be explained later.

Do Until

Dim myNumber As Integer = 0

Do Until myNumber = 5

Console.WriteLine("Pick a number between 1 and 6")

myNumber = Console.ReadLine()

If myNumber = 5 Then

Console.WriteLine("Yes 5, it is!")

Else

Console.WriteLine("Oops that's not the lucky...