ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Complex Numbers (https://www.excelbanter.com/excel-programming/302304-complex-numbers.html)

No Name

Complex Numbers
 
How do I do complex numbers in Visual Basic for Excel. I
installed the analysis add in so I can now do it in
Excel. However, I want Visual Basic to manipulate
complex numbers in my program. This is part of my basic
code that doesn't work. Thanks for the help.

wks_W.Range("AY" & i).Value = WorksheetFunction.complex
(1, 2)

or

wks_W.Range("AY" & i).Value = complex(1, 2)

Dana DeLouis[_3_]

Complex Numbers
 
Here are two ways.

In the vba editor, if you do "Not" have the following checked...
Tools|References... and a check on "atpvbaen.xls" then here is one way that
I use:

Sub Demo1()
Dim x
Const ImAbs As String = "ATPVBAEN.XLA!ImAbs"
x = Run("ImABS", "3+4i")
End Sub


However, if you do select "atpvbaen.xls", then it's much easier:

Sub Demo2()
Dim x
x = ImAbs("3+4i")
'or your example:
Range("A1") = Complex(1, 2)
End Sub


HTH
Dana DeLouis


wrote in message
...
How do I do complex numbers in Visual Basic for Excel. I
installed the analysis add in so I can now do it in
Excel. However, I want Visual Basic to manipulate
complex numbers in my program. This is part of my basic
code that doesn't work. Thanks for the help.

wks_W.Range("AY" & i).Value = WorksheetFunction.complex
(1, 2)

or

wks_W.Range("AY" & i).Value = complex(1, 2)





All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com