PowerBuilder编程基础(二)
条件分支结构
1. if ...then...end if
if a>b then a=a-1
end if
2 if ..then... else ...end if
3 if ..then elseif... else... end if
choose..case结构
string str
int i
i=5
choose case i
case 1
str="星期一"
case 2
str="星期二"
case 3
str="星期三"
case 4
str="星期四"
case 5
str ="星期五"
case 6
str ="星期六"
case 7
str ="星期天"
end choose
MessageBox("",str)
循环结构
for ..next 循环
例如:求1加到100的和
for a= 1 To 100 step 1
b+=a
next
MessageBox("","1加到100的和是"+string(b))
Do循环 (loop 只循环,next 自动递增 并循环)
DO...Loop
int a, b
a=1
Do Until a>100
b+=a
a++
Loop
MessageBox("","1加到100的和是"+string(b))
int a, b
a=1
Do while a<=100
b+=a
a++
Loop
MessageBox("","1加到100的和是"+string(b))
int a, b
a=1
Do
b+=a
a++
Loop until a>100
MessageBox("","1加到100的和是"+string(b))
int a, b
a=1
Do
b+=a
a++
Loop while a<=100
MessageBox("","1加到100的和是"+string(b))
****************************************
Goto continue 和 Exit (exit 相当于C#中的break关键字)
****************************************
返回和终止 return halt
浙公网安备 33010602011771号