Re: Passing an array from a VB.NET COM component to ASP



Thanks SG -

I should have mentioned that I had tried that first.
I get a type mismatch error when I use y(i)...

Microsoft VBScript runtime error '800a000d'

Type mismatch

I suspect that I ought to be doing something with marshalling, but I'm
just not comfortable enough with it to figure out what.

Brian

On Oct 14, 2:23 pm, Scuba Geek <mbi...@xxxxxxxxxxxxxxxx> wrote:
Hello Brian,

y.item is not how you access array members in VB6.

It should read y(i) instead.



"brian.ba...@xxxxxxx" wrote:
I've created a sample COM componenet in VB.NET and am having mixed
success utilizing it in an ASP application.
I am trying to pass an array of strings from the component to ASP,
without success.  I played with marshalling a bit, but I'm not very
familiar with it and wasn't successful.  Does anyone know what's wrong
with my code?

Thanks in advance!

- bab

Here is my component: (VB.NET)

---

Public Interface ILoginInfo
    Property LoginID() As String
    Function GetArray() As String()
    Function GetItemCount() As Integer
    Sub DoSomething()
End Interface

<ClassInterface(ClassInterfaceType.None), _
   Guid("ED6F5838-8B66-479b-97D6-BBAE12CD1E95")> _
    Public Class LoginInfo
    Implements ILoginInfo
    Private _LoginID As String
    Private _strArray As String()

    Public Property LoginID() As String Implements ILoginInfo.LoginID
        Get
            LoginID = _LoginID
        End Get
        Set(ByVal value As String)
            _LoginID = value
        End Set
    End Property

    Public Sub DoSomething() Implements ILoginInfo.DoSomething
        LoginID = "Something"

        ReDim _strArray(5)
        _strArray(0) = "First String"
        _strArray(1) = "Second String"
        _strArray(2) = "Third String"
        _strArray(3) = "Fourth String"
        _strArray(4) = "Fifth String"
    End Sub

    Public Function GetItemCount() As Integer Implements
ILoginInfo.GetItemCount
        GetItemCount = UBound(_strArray)
    End Function

    Public Function GetArray() As String() Implements
ILoginInfo.GetArray
        Return _strArray
    End Function
End Class

---

I use regasm to generate a type library, and import the class dll into
the GAC.  My sample ASP page is as follows:

<%

   Dim obj

   set obj = Server.CreateObject("myobject.LoginInfo")

   obj.Dosomething

   Response.write "LoginID: " & obj.LoginID & "<BR>"

   Dim i
   i = obj.GetItemCount
   Response.write "Item Count: " & i & "<br>"

   Dim x, y

   y = obj.getarray

   Response.write "UBound: " & Ubound(y) & "<BR>"

   for x = 0 to i - 1
           response.write x & ": " & y.item & "<br>"
   next

   set obj = nothing
%>

---

The page renders as follows:

LoginID: Something
Item Count: 5
UBound: 5

Microsoft VBScript runtime error '800a01a8'

Object required

/Default.asp, line 30

---- Hide quoted text -

- Show quoted text -

.



Relevant Pages

  • Re: 11-string recuerdos- where on the bell curve?
    ...   Yes, a couple of the ornaments in the first section did not come out ... which there is not room for improvement, slurs included, but I do not ... This is my recording of Recuerdos done on six string several years ... a heavier bass? ...
    (rec.music.classical.guitar)
  • Re: Export multiple versions of a query to separate Excel files
    ... If I try to run the code I can select the folder that I want to create ... Dim qdf As DAO.QueryDef ... Dim strSQL As String, strTemp As String, strMgr As String ...
    (microsoft.public.access.externaldata)
  • Re: Using String for new List name
    ...     for line in infile: ... and aclS represents "access control list String." ... My quest, if you will, is to create a list of syslog entries, each ... Since ACL rules can be written with a range of granularity, ...
    (comp.lang.python)
  • Re: Macro to delete rows until a row contains a certain text strin
    ... Dim rngStartCell As Range ... Dim strToFindStart As String ...     'Test if any rows between first and last identifiers ... starting cell to one row before the row containing "KM In". ...
    (microsoft.public.excel.programming)
  • Re: Excel Chart Macro Issue
    ... If the issue is string length, why would forming a large string at the end ... Sometimes this means setting up a summary range that the chart uses. ... Dim rDataX As Range ...   Dim wsData As Worksheet ...
    (microsoft.public.excel.programming)

Loading