vb问题。用select case语句方法写出分段函数?
展开全部
Private Sub Command1_Click()
Dim x As Integer, y As Double
x = Val(InputBox("enter data x:"))
Select Case x
Case Is > 20
y = x ^ 2 + 3 * x + 2
Case Is >= 10 And x <= 20
y = Sqr(3 * x) - 2
Case Is > 0 And x < 10
y = 1 / x + Abs(x)
End Select
Print Format(y, "#.0000")
End Sub
Dim x As Integer, y As Double
x = Val(InputBox("enter data x:"))
Select Case x
Case Is > 20
y = x ^ 2 + 3 * x + 2
Case Is >= 10 And x <= 20
y = Sqr(3 * x) - 2
Case Is > 0 And x < 10
y = 1 / x + Abs(x)
End Select
Print Format(y, "#.0000")
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询