VB编程:已知下面的分段函数,要求输入x,计算出y的值,x大于等于0时,y=1+x的平

VB编程:已知下面的分段函数,要求输入x,计算出y的值,x大于等于0时,y=1+x的平方 x小于0时,y=1减 2x

第1个回答  2012-05-29
窗体上添加2个text,1个command
Private Sub Command1_Click()
x = Text1.Text
If x >= 0 Then
y = 1 + x ^ 2
Else
y = 1 - 2 * x
End If
Text2.Text = y
End Sub本回答被提问者采纳
第2个回答  2012-05-29
可以加一个命令按钮,点击后开始运算,这个可以根据自己想法设置
在窗体上放置两个textbox,为text1和text2,分别输入x,显示y的值
dim x as integer,y as integer
x=val(text1)
select case 1
case is<0
y=1-2*x
case is>=0
y=(1+x)^2
end select
text2=str(y)

参考资料:case1

相似回答