The information in this article applies to:
SUMMARYBecause Microsoft Excel stores complex numbers as text, complex numbers cannot be formatted like real numbers. This article provides sample code for a user-defined function that applies number formats to complex numbers. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspComplex numbers are real and imaginary coefficients which combine to form a complex number. They are in the form of x+yi or x+yj where x is the real coefficient and y is the imaginary coefficient. Complex numbers always carry a suffix of the letter i or j. The function in this article takes three arguments: the number to be formatted, a format code for the real component, and a format code for the imaginary component. For example, the function
would display the complex number in cell A1 with two decimal places for the
real component and four decimal places for the imaginary component.
You can also use multisection formats to format positive, negative, and zero components differently. For example, the function
would have the same result as the earlier example, but with zero components
displaying as "0" rather than including extra zeroes to the right of the
decimal point. If you use a multisection format, the formats for negative
numbers must begin with a "-" (minus sign) as in the example.
Sample Visual Basic Procedure
Additional query words: 5.00a 5.00c 8.00 XL98 XL97 XL7 XL5
Keywords : kbprg kbdta kbdtacode PgmHowto KbVBA |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |