FIX: "Invalid Procedure Call" Error with Preserve Keyword (193092)
The information in this article applies to:
- Microsoft Data Access SDK 2.0
- Microsoft Data Access SDK 2.1
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q193092 SYMPTOMS
The following error occurs if a variant set equal to an Array() function is
redimensioned using the Preserve keyword:
Run-time error '5' "Invalid Procedure Call or Argument"
NOTE: This behavior occurs only under the following two conditions:
- If Microsoft Data Access Components (MDAC) 2.0 or Visual Studio 6.0
is installed on the computer.
-and- - If the array has not been initialized.
CAUSE
This error occurs with the newer version of the OLE automation core file,
(version 2.304261). The Oleaut32.dll file is installed in your system
directory when you install MDAC 2.0 or Visual Studio 6.0 products.
RESOLUTION
Here are two ways to resolve this problem:
Method One- Revert to the older version of Oleaut32.dll (version 2.20.4118).
This can be done by re-installing the Windows NT Service Pack 3, which
overwrites the newer version of the .dll file.
-or -
- Re-install Visual Basic 5.0, either Service Pack 2 or Service pack 3,
which also overwrites the newer version of the .dll file.
NOTE: The preceding workaround can only be used with a Visual Basic 5.0
application running with MDAC 2.0 installed on the computer. The newer
version of the automation file, Oleaut32.dll (version 2.304261), must be
present on a computer that runs a Visual Basic 6.0 application.
Method Two
You can choose to keep the newer version of the Oleaut32.dll file. However,
you cannot preserve your array unless it was initialized prior to the call.
For example:
Sub Command1_Click ()
Dim VarArr as Variant
Dim lngSubScript As Long
VarArr = Array()
' Get largest available subscript for the array.
lngSubScript = UBound(A)
If (lngSubScript <> -1) Then
' Re-allocate 5 elements of the array and preserve its values.
ReDim Preserve VarArr(5)
Else
' Re-allocate 5 elements of the array.
ReDim VarArr(5)
End If
End Sub
NOTE: The preceding workaround applies to both Visual Basic 5.0
applications and Visual Basic 6.0 applications running with the newer
version of the OLE automation file.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the
beginning of this article.
This bug has been corrected in Microsoft Visual Basic
Learning, Professional, and Enterprise Editions for Windows, version 6.0,
Service Pack 1.
REFERENCES
For additional information, please see the following articles in the
Microsoft Knowledge Base:
187282 INFO: List of Visual Basic Run-Time Files Installed by
Product
190130 INFO: Description of VB 6.0 Run Time and OLE Automation
Files
Modification Type: | Minor | Last Reviewed: | 3/21/2005 |
---|
Keywords: | kbADO210fix kbbug kbfix KB193092 |
---|
|