By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,411 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,411 IT Pros & Developers. It's quick & easy.

Type mismatch error when accessing an array

P: n/a
Hello,
I have a method on a com+ object that is returning an array of objects.

I know the array is popluated as calls to check the ubound and lbound
show valid values. However, any calls to get the value of a cell in the

array results in a type mismatch error.
Microsoft VBScript runtime (0x800A000D)
Type mismatch
/idmTest/userTest.asp, line 30
I have pasted below some of the samples that i have tried. Each results

in the error above. Any suggestions on how I can access this object
would be helpful.
' Call to get the array and to validate that it is an array.
Set userObj = Server.CreateObject("idmVBApi.ComUser")
userGrpAry = userObj.getUserGroups(5790)
arySize = ubound(userGrpAry)
response.write "userGrpAry size = " & lbound(userGrpAry) & " - " &
arySize & "<br>"
response.write "userGrpAry type isArray = " & isArray(userGrpAry) &
"<br>"
' the following fails
dim index
for index = lbound(userGrpAry) to ubound(userGrpAry)
response.Write "type = " & isobject(userGrpAry(index))
response.write userGrpAry(index).grpName
next
Calls to isNull(userGrpAry(index)) also fail.
Regards
Leslie

Oct 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
le**********@yahoo.com wrote:
Hello,
I have a method on a com+ object that is returning an array of
objects.


It's hard to say without having first-hand access to your code. Hopefully
what's written in these articles will help:

http://support.microsoft.com/default...b;EN-US;244012
http://support.microsoft.com/default...b;EN-US;197956

Building COM Components That Take Full Advantage of Visual Basic and
Scripting
http://msdn.microsoft.com/library/te...bscriptcom.htm

Q218454 - HOWTO: Implement Array Arguments in Visual C++ COM Objects for
Active Server Pages
http://support.microsoft.com/default.aspx?kbid=218454

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Oct 12 '05 #2

P: n/a
Bob,

Thanks for your help. I have pasted the code below withe some comments
to explain what I am doing. What is interesting is that I can access
the object just fine in VB.net. Its just through asp that i am
struggling.

' Com+ object code
<ComClass(ComUser.ClassId, ComUser.InterfaceId, ComUser.EventsId)> _
Public Class ComUser

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String =
"DDCA1246-62B9-40C2-B9DD-926808410D9C"
Public Const InterfaceId As String =
"0175C8FD-E0F1-4FEE-A0B4-48EE6C39DDF8"
Public Const EventsId As String =
"A7C3EE87-2BDB-4697-8781-F3CB6F68A46D"
#End Region

' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub

Public ComUser()

Public Function getUserGroups(ByVal userId As String) As
WSGroupValue()
Dim user As UserService
user = New UserService
Return user.getUserGroups(userId)
End Function

End Class

' asp code to call this object and related method
' this part works
Dim userObj
Dim grpVal
dim arySize

Set userObj = Server.CreateObject("idmVBApi.ComUser")
userGrpAry = userObj.getUserGroups(5790)
arySize = ubound(userGrpAry)

response.write "userGrpAry size = " & lbound(userGrpAry) & " - " &
arySize
response.write "userGrpAry type isArray = " & isArray(userGrpAry)

dim index
for index = lbound(userGrpAry) to ubound(userGrpAry)
' ***** each of these calls fails *****
response.Write "type = " & isobject(userGrpAry(index))
grpval = userGrpAry(index)
response.Write "Grp name = " & grpVal.grpName & "<br>"
next

Oct 12 '05 #3

P: n/a
le**********@yahoo.com wrote:
Bob,

Thanks for your help. I have pasted the code below withe some comments
to explain what I am doing. What is interesting is that I can access
the object just fine in VB.net. Its just through asp that i am
struggling.


That makes the articles i provided extremely relevant. Don't forget that
vbscript is a loosely-typed language, which makes communicating with a
strongly-typed language like VB.Net very tricky. Please carefully read those
articles. I'm sure at least one of them will contain the key to your
problem.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 12 '05 #4

P: n/a
Thanks Bob.

The answer was that in needed to return an array of objects and not an
array of a type.
ie. object() vs. WSGroupValue()

Oct 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.