SELECT Expression
[ CASE Expression [ , Expression ... ]
... ]
[ CASE Expression [ , Expression ... ]
... ]
[ ( 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.
Example:
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.
PUBLIC SUB Form_Open() 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 END SELECT NEXT PRINT a,b,c,d,e,f END