vb求分段函数的值。(要求用输入对话框输入x的值)马上开始考试了,在线等!

来源:百度知道 编辑:UC知道 时间:2024/06/05 12:53:01
x-21 x>0
y={
5+x^2 x<=0

马上开始考试了,在线等!

Private Sub Command1_Click()
Dim x as Single
Dim y as Single
x=Inputbox("Please input your x:")
If x<=0 then
y=5+x*x
Else
y=x-21
End f
Print y
End Sub

Private Sub Command1_Click()
Dim intX As Integer, intY As Integer
intX = InputBox("请输入 X 的值")
If intX > 0 Then
intY = intX - 21
Else
intY = 5 + intX * intX
End If
MsgBox intY
End Sub