خانه > lang > select 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs tr ar id vi ko ja ru zh zh_TW eo
قبلی  بعدی  ویرایش  تغییر نام  واگرد  Search  سرپرستی  
مستندات  
اخطار! این صفحه ترجمه نشده است.  مشاهده نسخه انگلیسی 
SELECT
SELECT [ CASE ] Expression
  [ CASE Expression [ TO Expression #2 ] [ , ... ]     ... ]
  [ CASE Expression [ TO Expression #2 ] [ , ... ]     ... ]
  [ { CASE ELSE | DEFAULT }     ... ]
END SELECT

Selects an expression to compare, and execute the code enclosed in the corresponding matching CASE statement.

If no CASE statement matches, the DEFAULT or CASE ELSE statement is executed.

A CASE statement is a list of single values or interval of two values separated by the TO keyword.

مثال

' You want to check the random function of a die.
' So you repeat the random function a thousand times
' and you count, how many times 1, 2, 3, 4, 5 or 6
' have been thrown.

DIM x AS Integer
DIM w AS Integer
DIM a AS Integer
DIM b AS Integer
DIM c AS Integer
DIM d AS Integer
DIM e AS Integer
DIM f AS Integer

FOR x = 1 TO 1000

  w = Int(Rnd(6) + 1)

  SELECT CASE w
    CASE 1
      a = a + 1
    CASE 2
      b = b + 1
    CASE 3
      c = c + 1
    CASE 4
      d = d + 1
    CASE 5
      e = e + 1
    CASE 6
      f = f + 1
    CASE ELSE
      PRINT "This is impossible!"
  END SELECT

NEXT

PRINT a, b, c, d, e, f

همچنین مشاهده کنید

ساختارها وتوابع تصمیم