The information in this article applies to:
SYMPTOMS
In Microsoft Excel or Microsoft Project, if you create a Visual Basic,
Applications Edition, macro that contains a variable with a type-
declaration character (for example "MyVar$"), and you use this variable as
an argument in the TimeValue or DateValue functions without assigning a
value to it, you may receive a general protection (GP) fault in the file
OLE2DISP.DLL when you run the macro. Some of the error messages you may
encounter include the following:
CAUSEThe TimeValue or the DateValue function must receive a string data type that is a valid time or date, respectively. If the variable used for the time or date argument has no value, the TimeValue or DateValue function cannot return a valid result. WORKAROUNDSMethod 1: Use a valid value for the time or date argument. For more information about the definition of a valid argument for the TimeValue and DateValue functions, see the appropriate topic in Visual Basic Reference Help.Method 2: Check the value of the variable before you use it. Use a conditional statement (such as IF) to compare the value of the argument to "" (two quotation marks). After this verification, use standard error-handling as described in Help. For example, you can use the "On Error" statement.Method 3: Avoid using the string type-declaration character ($). Instead of using a variable with a string type-declaration character (such as "MyVar$"), use DIM to declare its type, as in the following example:DIM MyVar as StringNOTE: A "type-mismatch" error will still occur if you pass this variable without assigning a value to it. STATUSMicrosoft has confirmed this to be a problem in Visual Basic Programming System, Applications Edition. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. REFERENCES
"Visual Basic User's Guide," version 5.0, Chapter 9
Additional query words: gpf error-handling handling
Keywords : |
Last Reviewed: October 19, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |