XL97: Only One Character Is Returned from a Declared Function (183086)
The information in this article applies to:
- Microsoft Excel 97 for Windows
This article was previously published under Q183086 SYMPTOMS
When you use a formula in a worksheet to call a function that is declared
in a Visual Basic module in Microsoft Excel 97, only one character may be
returned by the function.
WORKAROUND
You can work around this problem by creating a user-defined "wrapper" function to call the declared function.
Microsoft 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 a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
Example
In this example, you create a user-defined "wrapper" function to call the
declared function. You use the MessageBox function and the declaration in
the following example:
- Start the Visual Basic Editor (press ALT+F11).
- On the Insert menu, click Module.
- Type the following:
Declare Function MessageBox Lib "user32" Alias "MessageBoxA" _
(ByVal hwnd As Long, ByVal lpText As String, _
ByVal lpCaption As String, ByVal wType As Long) As Long
Function MyMessageBox(hwnd As Long, lpText As String, _
lpCaption As String, wType As Long) As Long
MyMessageBox = MessageBox(hwnd, lpText, lpCaption, wType)
End Function
- Switch to Microsoft Excel (press ALT+F11).
- In cell A1, type the following formula:
=MyMessageBox(0,"Works fine in Excel 97","Title Bar",0)
This function is a wrapper function that is entered directly into
the worksheet. You can use the wrapper function without experiencing the
problem listed at the beginning of the article.
Notice when you press ENTER, the title bar and message text are complete.
- Click OK.
STATUS
This behavior is by design of Microsoft Excel 97.
Modification Type: | Major | Last Reviewed: | 6/23/2005 |
---|
Keywords: | kbbug kbdtacode kbnofix kbProgramming KB183086 |
---|
|