home *** CD-ROM | disk | FTP | other *** search
Visual Basic class definition | 2006-10-05 | 947 b | 40 lines |
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "Quadratic"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = True
- ' class to calculate quadratic equation
- ' r=-b +/- sqrt(b^2-4ac)/2a
- ' where y=ax^2+bx+c
- Dim r(2)
-
- Public Property Get R1()
- R1 = r(0)
- End Property
-
- Public Property Get R2()
- R2 = r(1)
- End Property
-
- Public Function Quadratic(a, b, c)
- temp = (b * b - 4 * a * c)
- If temp < 0 Then
- ' no rational solution
- r(0) = "Empty"
- r(1) = "Empty"
- Quadratic = "No Solution"
- End If
- temp = Sqr(temp)
- r(0) = (-b + temp) / (2 * a)
- r(1) = (-b - temp) / (2 * a)
- Quadratic = r(0) & ":" & r(1)
- End Function
-