VB judgment statements and loop statements and vb judgment statements

Source: Internet
Author: User

VB judgment statements and loop statements and vb judgment statements
Judgment statement • If statement

The if statement can be written in four ways:

First Syntax: If condition judgment statement then program code

Second Syntax: If condition judgment statement then program code else program code

Third Syntax:

If condition judgment statement then

Code

Else

Code

End if

Fourth syntax

If condition judgment statement then

Elseif condition judgment statement then

Code

Elseif condition judgment statement then

Code

......

Else

Code

End if

 

• Select statement

The syntax of the Select statement is:

Select Case Condition Statement

Case Condition Statement result 1

Code

Case Condition Statement result 2

Code

......

Case else

Code

End Select

Loop statement

• Do statement

There are four types of Do statement Syntax:

In the code of the following four do statements, you can add the exit do statement to exit the loop where appropriate.

The first do statement:

Do While condition judgment statement

Code

Loop

Note: When the condition judgment statement is true, the program code is repeatedly executed until the condition is false.

 

The second do statement:

Do Until condition judgment statement

Code

Loop

 

Note: If the condition-based statement is true, repeated program code execution is stopped.

 

Third do statement:

Do

Code

Loop While condition judgment statement

Note: The program code is executed first, and the condition judgment statement is judged. The running result is the same

The first do while statement.

The fourth do statement:

Do

Code

Loop Until condition judgment statement

Note: first run the code, and then judge the do until statement of the second type.

• For statement

The syntax of the For statement is as follows:

First For statement

For value variable = start value to end value step interval value

Code

Next value variable

Note: In this syntax, the start and end numeric variables are the same variable.

The second For statement

For each element variable in object or array name

Code

Next

 

• While statement

Syntax:

While condition judgment statement

Code

End While

Note:

This statement and the do statement have the same meaning. The main difference is that the do loop

First, perform a loop unconditionally, and then make a judgment, while the while loop is first

Perform the judgment and then execute the loop. If the initial condition is false, the loop

It won't be done once.

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.