有人可以幫我解AX^2+BX+C=0的圖嗎我不會畫圖>.<"我有求解的答案可是沒有畫圖的拜託幫一下謝謝!!!
Dim A, B, C As Single
Dim D As Single
Private Sub Command1_Click()
Dim X, Y As Single
A = Val(Text1.Text)
B = Val(Text2.Text)
C = Val(Text3.Text)
If A = 0 Then
  If B = 0 Then
   If C = 0 Then
    Text6 = "無限多解"
   Else
    Text6 = "無解"
   End If
  Else
   Text4 = Str(Round(-C / B, 2))
   Text6 = "只有一解"
  End If
 Else
  D = (B ^ 2) - 4 * A * C
  X = Round((-B + Sqr(Abs(D))) / (2 * A), 2)
  Y = Round((-B - Sqr(Abs(D))) / (2 * A), 2)
   Select Case D
    Case 0
     For T = -20 To 20 Step 0.005
     Text4 = Str(X)
     Text5 = Str(Y)
     Text6 = "相同實根"
     Next T
    Case Is > 0
     Text4 = X
     Text5 = Y
     Text6 = "相異實根"
    Case Is < 0
     Text4 = Round((-B / (2 * A)), 2) & "+" & Round((Sqr(Abs(D))) / (2 * A), 2) & "i"
     Text5 = Round((-B / (2 * A)), 2) & "-" & Round((Sqr(Abs(D))) / (2 * A), 2) & "i"
     Text6 = "共軛虛根"
   End Select
 End If
End Sub
arrow
arrow
    全站熱搜

    vbqa 發表在 痞客邦 留言(2) 人氣()