Private Sub Form_Click() '点击窗体运行
Dim x As Integer, y As Double
x = Val(InputBox(请输入一个整数))
If x < -5 Then
y = 2 * x - 1
ElseIf x < 0 Then
y = 3 * x ^ 2 + 5 * x - 1
ElseIf x <= 5 Then
y = Abs(x ^ 2 - 100)
ElseIf x < 20 Then
y = Sin(5 * x + 7)
Else
y = 3 * x ^ 3 - 2 * x ^ 2 - x + 1
End If
MsgBox "计算结果为:" & y
End Sub