|
Les 7 - If Then Else |
|
If then else is letterlijk vertaald “als dan anders” . Dit is de meest gebruikte functie in welke programmeer taal dan ook. Voorbeeld : If a > 10 then label1.caption = “hallo” Else label1.caption = “Dag” Endif Uitleg. Als a groter is dan 10 doe dan label1.caption wordt “hallo” als a dat niet is doe dan : label1.caption wordt “Dag” Je kan ook alleen if gebruiken : Voorbeeld : If a > 10 then label1.caption = “hallo” Endif De volgende operatoren kan je gebruiken: if a=1 then ‘ Als a gelijk is aan 1 then if a<>1 then ‘ Als a ongelijk is aan 1 then if a>1 then ‘ Als a groter is dan 1 then if a<1 then ‘ Als a kleiner is aan 1 then if a>=1 then ‘ Als a groter of gelijk is aan 1 then if a<=1 then ‘ Als a kleiner of gelijk is aan 1 then Je kan ook meerdere vergelijkingen gebruiken If a > 10 then label1.caption = “hallo” Elseif label1.caption = “Weet het nog niet” Else label1.caption = “Dag” Endif Of dit : If a > 10 And a < 20 then label1.caption = “hallo” Endif Wanneer a groter is dan 10 EN a kleiner is dan 20 Of dit : If a > 10 Or a < 5 then label1.caption = “hallo” Endif Wanneer a groter is dan 10 OF a kleiner is dan 5
Ga verder met Les 8 |
|
|
|
|
|
|
|
|
|
|
|
|
copyright © 2000 - 2008 Majosoft |
|||
|
|
|||