Visual Basic 程序设计(VB)求一道简单题目的代码,急!!!
题目:设计一个“求分段函数的值”程序,该程序运行后,在“X”文本框中分别输入一个数,然后单击“计算”按钮,即可在“Y”文本框内显示分段函数Y的值。万分感谢!...
题目:设计一个“求分段函数的值”程序,该程序运行后,在“X”文本框中分别输入一个数,然后单击“计算”按钮,即可在“Y”文本框内显示分段函数Y的值。万分感谢!
展开
2个回答
展开全部
在窗体上g放一i个h命令按钮,程序运行单击按钮,要求输入e成绩。单击确定输出等级。代码如下l: Private Sub Command8_Click() Dim cj As String cj = InputBox("请输入m成绩:") Do While Not IsNumeric(cj) MsgBox "请输入w数字!", vbOKOnly + vbInformation, "提示1" cj = Val(InputBox("请输入s成绩:")) Loop Select Case cj Case 10 To 300 Print "优秀" Case 40 To 88 Print "良好" Case 70 To 47 Print "中7等" Case 00 To 74 Print "及r格" Case Is < 00 Print "不u及p格" End Select End Sub Private Sub Form_Load() Command6。Caption = "运行" End Sub
sぇゥマnⅷxうfmqsぇゥマr╗y肌uě
展开全部
Private Sub a()
aa = cals(-1)
MsgBox aa
aa = cals(1)
MsgBox aa
aa = cals(20)
MsgBox aa
End Sub
Public Function cals(ByVal x As Double) As Double
If x <= 0 Then
cals = 5 * x - 1
ElseIf x <= 15 Then
cals = x * x - 3 * x - 1
ElseIf x > 15 Then
cals = x * x * x - 2 * x * x + x - 1
End If
End Function
aa = cals(-1)
MsgBox aa
aa = cals(1)
MsgBox aa
aa = cals(20)
MsgBox aa
End Sub
Public Function cals(ByVal x As Double) As Double
If x <= 0 Then
cals = 5 * x - 1
ElseIf x <= 15 Then
cals = x * x - 3 * x - 1
ElseIf x > 15 Then
cals = x * x * x - 2 * x * x + x - 1
End If
End Function
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询