|
|
|
Click here to copy the following block | Option Explicit
Public Real As Double Public Imaginary As Double
Function Init(Real As Double, Imaginary As Double) As CComplexNumber Me.Real = Real Me.Imaginary = Imaginary Set Init = Me End Function
Function Complex(Real As Double, Imaginary As Double) As CComplexNumber Set Complex = New CComplexNumber Complex.Real = Real Complex.Imaginary = Imaginary End Function
Function Add(other As CComplexNumber) As CComplexNumber Real = Real + other.Real Imaginary = Imaginary + other.Imaginary Set Add = Me End Function
Function Add2(Real As Double, Imaginary As Double) As CComplexNumber Set Add2 = New CComplexNumber Add2.Real = Me.Real + Real Add2.Imaginary = Me.Imaginary + Imaginary End Function
Function Subtract2(Real As Double, Imaginary As Double) As CComplexNumber Set Subtract2 = New CComplexNumber Subtract2.Real = Me.Real - Real Subtract2.Imaginary = Me.Imaginary - Imaginary End Function
Function Multiply2(Real As Double, Imaginary As Double) As CComplexNumber Set Multiply2 = New CComplexNumber Multiply2.Real = (Me.Real * Real - Me.Imaginary * Imaginary) Multiply2.Imaginary = Me.Real * Imaginary + Me.Imaginary * Real End Function
Function Divide2(Real As Double, Imaginary As Double) As CComplexNumber Set Divide2 = New CComplexNumber Dim sum As Double sum = Real * Real + Imaginary * Imaginary Divide2.Real = (Me.Real * Real + Me.Imaginary * Imaginary) / sum Divide2.Imaginary = (Me.Imaginary * Real - Me.Real * Imaginary) / sum End Function
Function Text() As String If Imaginary = 0 Then Text = LTrim$(Real) ElseIf Real = 0 Then Text = LTrim$(Imaginary) & "i" ElseIf Imaginary > 0 Then Text = LTrim$(Real) & "+" & LTrim$(Imaginary) & "i" Else Text = LTrim$(Real) & LTrim$(Imaginary) & "i" End If End Function |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|