Share until loop in vb.net

ngodanhuu.binh

New member
## cho đến khi vòng lặp trong vb.net

Vòng lặp `cho đến` trong VB.NET là vòng lặp thử nghiệm trước thực thi một khối mã miễn là một điều kiện được chỉ định là sai.Cú pháp cho vòng lặp `cho đến khi như sau:

`` `VBNet
Làm cho đến khi điều kiện
// Mã được thực thi
Vòng
`` `

Biểu thức `điều kiện` được đánh giá ở đầu mỗi lần lặp của vòng lặp.Nếu biểu thức là đúng, cơ thể vòng lặp bị bỏ qua và lần lặp tiếp theo bắt đầu.Nếu biểu thức là sai, cơ thể vòng lặp được thực thi và điều kiện được đánh giá lại.Quá trình này tiếp tục cho đến khi điều kiện trở thành đúng, tại thời điểm đó, vòng lặp chấm dứt.

Ví dụ: mã sau in các số từ 1 đến 10:

`` `VBNet
Dim I As Integer

Cho i = 1 đến 10
Console.WriteLine (i)
Tiếp theo tôi
`` `

Vòng lặp `cho đến khi` cũng có thể được sử dụng với câu lệnh `exit do` để chấm dứt vòng lặp sớm.Ví dụ: mã sau in các số từ 1 đến 10, nhưng nó dừng nếu số chia hết cho 3:

`` `VBNet
Dim I As Integer

Cho i = 1 đến 10
Nếu tôi mod 3 = 0 thì
Thoát khỏi làm
Kết thúc nếu

Console.WriteLine (i)
Tiếp theo tôi
`` `

## hashtags

* #vb.net
* #Loops
* #Conditionals
* #Programming
* #tutorial
=======================================
## Until loop in VB.NET

The `Until` loop in VB.NET is a pre-test loop that executes a block of code as long as a specified condition is false. The syntax for the `Until` loop is as follows:

```vbnet
Do Until condition
// code to be executed
Loop
```

The `condition` expression is evaluated at the beginning of each iteration of the loop. If the expression is true, the loop body is skipped and the next iteration begins. If the expression is false, the loop body is executed and the condition is evaluated again. This process continues until the condition becomes true, at which point the loop terminates.

For example, the following code prints the numbers from 1 to 10:

```vbnet
Dim i As Integer

For i = 1 To 10
Console.WriteLine(i)
Next i
```

The `Until` loop can also be used with the `Exit Do` statement to terminate the loop early. For example, the following code prints the numbers from 1 to 10, but it stops if the number is divisible by 3:

```vbnet
Dim i As Integer

For i = 1 To 10
If i Mod 3 = 0 Then
Exit Do
End If

Console.WriteLine(i)
Next i
```

## Hashtags

* #vb.net
* #Loops
* #Conditionals
* #Programming
* #tutorial
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top