Article ID: 112629 - Last Review: October 11, 2006 - Revision: 1.3 Incorrect Use of "Is" Function Causes GP FaultThis article was previously published under Q112629 On This PageSYMPTOMS
In Microsoft Excel version 5.0 for Windows, if you use the Visual Basic for
Applications "Is" function incorrectly, you may receive a general
protection (GP) fault.
MORE INFORMATION
The "Is" function is used to compare two object reference variables. The
result of an Is operation is either TRUE (if the variables both refer to
the same object) or FALSE (if they do not).
For example, if you have the following code:
Alpha Is Charlie
Note that Bravo Is <object>, where <object> is Alpha, Charlie, or Delta,
will return FALSE, because the value of Bravo is not the same as the value
of Alpha, Charlie, or Delta, even though they both refer to the same
object.
Alpha Is Delta Charlie Is Delta If you use the "Is" function to compare a valid object reference (for example, Alpha) to an invalid object reference (for example, a numeric value, a string, or any other item that is not an object), you may receive a GP fault. To prevent this error from occurring, make sure both items being compared are valid objects. Visual Basic Code ExampleMicrosoft provides examples of Visual Basic for Applications procedures 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. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.The following code example illustrates the proper use of the "Is" function. To run this example, position the cursor in the line that reads "Sub GoodIsSubroutine()" and either press the F5 key or choose Start from the Run menu. | Article Translations
|


Back to the top
