


| Phát biểu rẽ nhánh Select...Case |
Phát biểu rẽ nhánh Select...CaseCú pháp
Select Case TestExpression Case Expressionlist [Statements] Case Else [elseStatements] End Select TestExpression: là biểu thức bắt buộc, giá trị thuộc một trong các loại dữ liệu sau: Boolean, Byte, Char, Date, Double, Decimal, Integer, Long, Object, Short, Single, String. Expressionlist: phát biểu yêu cầu nằm trong Case, trong Case có thể là mệnh đề hay biểu thức, chúng cách nhau dấu ",". Ngoài ra các biểu thức trong Case còn sử dụng từ khóa To để diễn giải khoảng giá trị, Is là biểu thức so sánh. Ví dụ1: Case 1 To 4,5,6,7, To 9,11,13, Is>MaxNumber Ví dụ 2: Dim Number As Integer=8 Select Number Case 1 to 5 Response.write("Từ 1 đến 5") Case 6,7,8 Response.write("Từ 6 đến 8") Case 8 to 10 Response.write("Từ 8 đến 10") Case Else Response.write("Không tồn tại giá trị") End Select |
| < Trước | Tiếp > |
|---|