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

 

netherlands

Heeft u ook een leuke hobby en wilt u die ook graag tonen ? Stuur een email naar info@majosoft.com Wij maken voor u de site als u de gegevens aan kan leveren.

england

Do you have also a nice hobby and you want to show it. Please send an email to info@majosoft.com . We make the site if you can deliver the information.

germany

Haben Sie auch ein Hobby und wollen sie das sehn lassen. Bitte schicken Sie eine email zu info@majosoft.com . Wir machen die zeite fur ihn, wenn sie uns die information geben.

copyright © 2000 - 2008 Majosoft
www.majosoft.com
Hosted by
www.yourhosting.nl