In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to use VB.NET conditional branch statements. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
VB.NET conditional branching statement I. simple If conditional statement
Conditional expressions in special statement blocks called branch structures are used to control which statements are executed and in what order in the program. The "If...Then" branch structure calculates the condition value in the program and determines what to do next based on the condition value. The simplest "If...Then" branch structure can be written on only one line:
If Condition Then
Statement [Else statement]
Note: the "If...Then" branch structure is used to add logic control to the program. Here, "Condition" is a conditional expression, and "Statement" is a conditional Visual Basic statement. For example:
If Score > = 20 Then Label1.Text= "You Win!" Is a branch structure that uses the following conditional expression: Score > = 20
Based on the value of this expression, the program decides whether to set the "Text" property of the Label1 object to "You Win!". If the value of the "Score" variable is greater than or equal to 20, visual Basic sets the value of this property, otherwise, Visual Basic skips the assignment statement and executes the next line of statements in the event procedure. The result of such comparison operations is either "True" or "False", and conditional expressions never produce ambiguous values.
VB.NET conditional branching statement II. If...Then...Else statement
Visual Basic also supports another format of the "If...Then" branch structure, which contains several conditional expressions and consists of multiple lines of statements, including the important keywords "ElseIf", "Else", and "End If".
If Condition1 Then Statements ElseIf Condition2 Then Statements [other ElseIf clauses and their corresponding execution statements] Else Statements End If
In this structure, "Condition1" is calculated first. If the value of this conditional expression is "True", then the statement under this conditional expression is executed; if the value of * condition is not "True", then the value of the second expression (Condition2) is evaluated, and if the value of the second condition is "True", then the statement block under this conditional expression is executed (if more conditions are to be judged, continue to add the "ElseIf" clause and the statement block under this clause)
If none of the conditional expressions have a value of "True", then execute the statement block under the "Else" clause; * *, and the entire structure ends with the "End If" keyword. The multi-line "If...Then" structure is particularly suitable for proration problems, such as tax calculations. The following code shows how to use a multi-line "If...Then" structure to determine the progressive tax calculation problem (the correspondence between income and tax rates is taken from the 1997 tax rate table for domestic income services in the United States):
If AdjustedIncome
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.