XL98: Indexes for Methods and Collections Are Rounded (190357)
The information in this article applies to:
- Microsoft Excel 98 Macintosh Edition
This article was previously published under Q190357 SYMPTOMS
In Microsoft Excel 98 Macintosh Edition, if you specify a decimal value for
the index of a method or collection in a Visual Basic for Applications
macro, the index is rounded to the nearest whole number. However, in
earlier versions of Microsoft Excel, the index is truncated rather than
rounded. Because of this difference, you may receive different results from
different versions of Microsoft Excel.
CAUSE
Microsoft Excel 98 uses strict typing for arguments of collections
and methods. If an argument is typed as an integer, decimal values that are
passed to that argument are automatically rounded.
RESOLUTIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements.
You should not rely on Microsoft Excel to automatically convert your
decimal values for indexes. If you require that the index is to be
truncated in all versions of Microsoft Excel, use the INT function:
MsgBox Sheets(INT(1.6)).Name
If you require that the index is to be rounded in all versions of Microsoft
Excel, use the CInt function:
MsgBox Sheets(CInt(1.6)).Name
Modification Type: | Major | Last Reviewed: | 6/17/2005 |
---|
Keywords: | kbdtacode kbprb kbProgramming KB190357 |
---|
|