編制程序Command1_Click,輸入x、n后,根據下列公式計算多項式y的值。要求使用Select Case陳述句。
X2+1 n=1,2,3
y= X1/3-5 n=5
X3+x2-1 8<=n
uj5u.com熱心網友回復:
就是n處于不同值的時候, x和y用不同的計算方式咯, 分段函式.這個你只要看一看select的語法說明和歷程就能理解的.
uj5u.com熱心網友回復:
你哪里不會?uj5u.com熱心網友回復:
Sub test()b
Dim n As Integer
Dim y As Double
Dim x As Double
'輸入 值
n = 5
Select Case n
Case 1, 2, 3
y = x ^ 2 + 1
Debug.Print y
Case 5
y = x ^ (1 / 3) - 5
Case Is >= 8
y = x ^ 3 + x ^ 2 - 1
End Select
MsgBox y '輸出答案
End Su
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/139612.html
標籤:VBA
