![]() You can use the logical operators to extend the If Else Statements and use two conditions, for example if a = b And a > 19 Then OperatorĪnd Operator – If both conditions are true, then the result is true If Else Statements can become quite long, so it is best to use a Select Case Statement which will be addressed in the next lesson. The If Else Statement will see if the statements are true: if they are it will print out the correct message, and if they are false it will print the last message. However, we have made a new string variable called “message” this was made to avoid repeating the console message. The process is the same as before, but we have more decisions. If username = "Admin" And password = 2012 ThenĬonsole.WriteLine("Oops could not find you!") If username = "Dave" And password = 12345 Then You can also have a nested If Else Statement. You are also using the logical operator And which will be explained later. So if username = “Asim” AND password = 243, then “Welcome Asim” is displayed otherwise “Access Denied” is displayed. ![]() Then we compare those values to the values in our If Statement. You have two variables (string/integer) which we use to store the values the user enters when prompted. ![]() This is similar to the above If Statement. ![]() If username = "Asim" And password = 243 Then Comment out the other If Statement ( CTRL+K+C) and copy the following code: Dim username As String ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |