faloyoo.blogg.se

Microsoft visual basic for applications select if included
Microsoft visual basic for applications select if included







microsoft visual basic for applications select if included

Not Operator – If the condition is false, then the result will be true, or vice versa.Įxample of Logical And Operator Dim a As IntegerĬonsole.WriteLine("A is greater than 100, but less than 150, A = " + a.ToString()) Or Operator – If either of the conditions are true, the result will be true 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

microsoft visual basic for applications select if included

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









Microsoft visual basic for applications select if included