當前位置:編程學習大全網 - 電腦編程 - vb問題。用select case語句方法寫出分段函數?

vb問題。用select case語句方法寫出分段函數?

Private Sub Command1_Click()

Dim x As Integer, y As Double

x = Val(InputBox("enter data x:"))

Select Case x

Case Is > 20

y = x ^ 2 + 3 * x + 2

Case Is >= 10 And x <= 20

y = Sqr(3 * x) - 2

Case Is > 0 And x < 10

y = 1 / x + Abs(x)

End Select

Print Format(y, "#.0000")

End Sub

  • 上一篇:請歐姆龍PLC高手指教
  • 下一篇:編程作業英語
  • copyright 2024編程學習大全網