条件与分支
不同时间的问候
If Clock.Hour<12 Then TextWindow.WriteLine("早上好!") EndIf If Clock.Hour>=12 Then TextWindow.WriteLine("下午好!") EndIf |
换种思路,再把程序实现一遍
If Clock.Hour<12 Then TextWindow.WriteLine("早上好!") Else TextWindow.WriteLine("下午好!") EndIf |
早上好,下午好,晚上好
If Clock.Hour<12 Then TextWindow.WriteLine("早上好!") ElseIf Clock.Hour >=12 and Clock.Hour<18 then TextWindow.WriteLine("下午好") Else TextWindow.WriteLine("晚上好") EndIf |
还有一种分支结构,不推荐使用,等我们学到微机原理与接口的课程中会发现,所有的循环本质上就是分支结构。
这里我们实现分支循环输出1到10
i=1 start: TextWindow.WriteLine(i) i=i+1 If i<11 Then Goto start EndIf |