if if Dim x as single Dim y

  • Slides: 15
Download presentation

行if语句 块if语句 Dim x as single Dim y as single X=inputbox(“请输入自变量X”) If x<=0 then

行if语句 块if语句 Dim x as single Dim y as single X=inputbox(“请输入自变量X”) If x<=0 then y=x^2+1 else y=x^2 -x+1 Print “y=“; y Dim x as single Dim y as single X=inputbox(“请输入自变量X”) If x<=0 then y=x^2+1 else y=x^2 -x+1 endif Print “y=“; y

程序: Dim a , b, c as single Dim max as single a=inputbox(“请输入a的值 ”)

程序: Dim a , b, c as single Dim max as single a=inputbox(“请输入a的值 ”) b=inputbox(“请输入b的值 ”) c=inputbox(“请输入c的值 ”) If a>b then max=a else max=b If c>max then max=c Print “max=“; max

方法二: Dim a, b, c as single a=text 1. text b=text 2. text c=text

方法二: Dim a, b, c as single a=text 1. text b=text 2. text c=text 3. text If a>b then max=a else max=b If c>max then max=c Text 4. text=max

多重语句: If 条件 then 语句 1 Else if 条件 then 语句 2 else 语句

多重语句: If 条件 then 语句 1 Else if 条件 then 语句 2 else 语句 3 endif