发布网友 发布时间:2024-10-23 22:49
共1个回答
热心网友 时间:2024-10-30 13:02
还是我来帮你做吧,你可以直接向我提问呀!呵呵呵,你等我会,开始做了哦!
第一题用IF语句好了:
Private Sub Command1_Click()
Dim x As Integer, y As Integer
x = InputBox("请输入X的值")
If x < 0 And x >= -10 Then
y = 2 * x + 20
ElseIf x >= 0 And x < 20 Then
y = 20
ElseIf x >= 20 And x < 40 Then
y = 30 - 2 * x
ElseIf x >= 40 And x < 50 Then
y = 50 - x
End If
Print y
End Sub
接着做第二种select:
Private Sub Command1_Click()
Dim x As Integer, y As Integer
x = InputBox("请输入X的值")
Select Case x
Case -10 To 1
y = 2 * x + 20
Case 0 To 19
y = 20
Case 20 To 39
y = 30 - 2 * x
Case 40 To 50
y = 50 - x
End Select
Print x
End Sub