关于VB的问题 Private Sub Command1_Click() Dim x As Single, z As Single, y As Single x = Val(Text1.
PrivateSubCommand1_Click()DimxAsSingle,zAsSingle,yAsSinglex=Val(Text1.Text):z=Val(Tex...
Private Sub Command1_Click()
Dim x As Single, z As Single, y As Single
x = Val(Text1.Text): z = Val(Text2.Text)
If z < 0 Then
If x < -10 Then
y = x ^ 2 + z ^ 2
Else
y = x + z
End If
Else
If x < -30 Then
y = x / z + 3.89
ElseIf x < -8 Then
y = x * Sin(z)
Else
y = Abs(x - z) ^ 0.5
End If
End If
Text3.Text = Str(y)
End Sub
如果我输入x=-38.9,z=10,结果为什么不是0? 展开
Dim x As Single, z As Single, y As Single
x = Val(Text1.Text): z = Val(Text2.Text)
If z < 0 Then
If x < -10 Then
y = x ^ 2 + z ^ 2
Else
y = x + z
End If
Else
If x < -30 Then
y = x / z + 3.89
ElseIf x < -8 Then
y = x * Sin(z)
Else
y = Abs(x - z) ^ 0.5
End If
End If
Text3.Text = Str(y)
End Sub
如果我输入x=-38.9,z=10,结果为什么不是0? 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim x As Single, z As Single, y As Single
x = Val(Text1.
???
nei rong bu quan a
Dim x As Single, z As Single, y As Single
x = Val(Text1.
???
nei rong bu quan a
追问
我是菜鸟,请问应该怎样改?
请指教
追答
x=-38.9,z=10
If z < 0 Then '因为Z=10不满足z<0的条件就直接进入这个IF的else中,就是***的地方
If x < -10 Then
y = x ^ 2 + z ^ 2
Else
y = x + z
End If
**** Else
If x < -30 Then‘因为x=-38<-30所以 y=x/z+3.89=-3.8/10+3.89=0.09,所以Text3.Text = Str(y)
=0.09,别忘了你的y也是定义的single,要是定义为integer,那么y=0了
y = x / z + 3.89
ElseIf x < -8 Then
y = x * Sin(z)
Else
y = Abs(x - z) ^ 0.5
End If
End If
Text3.Text = Str(y)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询