home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 November - Disc 2 / PCNET_CD_2006_11_2.iso / apps / Swishstudio2.exe / Main / Quadratic.cls < prev    next >
Encoding:
Visual Basic class definition  |  2006-10-05  |  947 b   |  40 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "Quadratic"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. ' class to calculate quadratic equation
  15. ' r=-b +/- sqrt(b^2-4ac)/2a
  16. ' where y=ax^2+bx+c
  17. Dim r(2)
  18.  
  19. Public Property Get R1()
  20.     R1 = r(0)
  21. End Property
  22.  
  23. Public Property Get R2()
  24.     R2 = r(1)
  25. End Property
  26.  
  27. Public Function Quadratic(a, b, c)
  28.     temp = (b * b - 4 * a * c)
  29.     If temp < 0 Then
  30.         ' no rational solution
  31.         r(0) = "Empty"
  32.         r(1) = "Empty"
  33.         Quadratic = "No Solution"
  34.     End If
  35.     temp = Sqr(temp)
  36.     r(0) = (-b + temp) / (2 * a)
  37.     r(1) = (-b - temp) / (2 * a)
  38.     Quadratic = r(0) & ":" & r(1)
  39. End Function
  40.