PRB: Returning a UDT from a VB COM Object Brings an ErrorID: Q224422
|
When you return a user-defined data type (UDT) from a Visual Basic COM object, you might get one of the following error messages:
Microsoft VBScript runtime error '800a01a8'
Object required
-or-
Response object error 'ASP 0106 : 80020005'
Type Mismatch
?
An unhandled data type was encountered
User-defined data types are not supported in the current version of Active Server Pages (ASP).
Active Server Pages does not support UDTs, but you can work around this by creating a new class to handle the data in place of the UDT and setting the instancing property to PublicNotCreateable. This will ensure that you can pass the necessary information to and from ASP, as well as ensuring that the class cannot be created outside of the DLL.
This behavior is by design.
Public Type TestUDT
strName as String
strDept as String
End Type
Public Function TestMethod() As Variant
Dim udtTestData As TestUDT
udtTestData.strDept = "TestDept"
udtTestData.strName = "TestName"
TestMethod = udtTestData
End Function
<%
Dim objTest, udtData
Set objTest = Server.CreateObject("VBUDTPrj.VBUDTObj")
udtData = objTest.TestMethod()
Response.Write( "Name = " & udtData.strName & "<BR>" )
Response.Write( "Dept = " & udtData.strDept & "<BR>" )
%>
Microsoft VBScript runtime error '800a01a8'
Object required
See the TYPE statement in the Visual Basic Documentation.
Additional query words:
Keywords : kbsample kbASP kbASP400 kbCOMt kbVBp500 kbVBp600 kbGrpASP
Version : WINDOWS:5.0,6.0; winnt:
Platform : WINDOWS winnt
Issue type : kbprb
Last Reviewed: May 25, 1999