Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/c327781/sibertec.com/index.php:1) in drupal_send_headers() (line 1485 of /hsphere/local/home/c327781/sibertec.com/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/c327781/sibertec.com/index.php:1) in drupal_send_headers() (line 1485 of /hsphere/local/home/c327781/sibertec.com/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/c327781/sibertec.com/index.php:1) in drupal_send_headers() (line 1485 of /hsphere/local/home/c327781/sibertec.com/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/c327781/sibertec.com/index.php:1) in drupal_send_headers() (line 1485 of /hsphere/local/home/c327781/sibertec.com/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/c327781/sibertec.com/index.php:1) in drupal_send_headers() (line 1485 of /hsphere/local/home/c327781/sibertec.com/includes/bootstrap.inc).
  • Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/c327781/sibertec.com/index.php:1) in drupal_send_headers() (line 1485 of /hsphere/local/home/c327781/sibertec.com/includes/bootstrap.inc).

Passing VBA Collections to a .Net Com Interop Class

I recently had the need to use the .Net Com interop features to pass a collection from a Microsoft Access VBA application to a VB.Net class. Apparently VBA collections and .Net collections are not compatible because it didn't work at all. So, I did what any decent programmer would do, I Googled it. I found several suggestion, none of which worked completely. I eventually decided to use the method below. It requires that the VBA application pass a Collection object to the .Net class. The .Net class can then work with the collection, and even return it to the VBA application.


Namespace TestNamespace

    ''' 
    ''' Implement an interface so changes to the class will not break the com link.
    ''' 
    ''' 
     _
    Public Interface ITestClass
         Property TestCollection() As Object
    End Interface

     _
    Public Class TestClass
        Implements ITestClass

        ' the collection is passed as type object
        Dim m_Col As Object

        Public Property TestCollection() As Object Implements ITestClass.TestCollection
            Get
                Return m_Col
            End Get
            Set(ByVal value As Object)
                m_Col = value
                Dim t As Type = value.GetType
                Dim itemCount As Integer = CInt(t.InvokeMember("Count", Reflection.BindingFlags.InvokeMethod, Nothing, value, Nothing))
                MsgBox("Count = " & CStr(itemCount))

                ' show the first item
                If itemCount > 0 then

                    ' with VBA collections, the first index is 1, not 0
                    MsgBox(t.InvokeMember("Item", Reflection.BindingFlags.InvokeMethod, Nothing, value, New Object() {1}))

                End If

                ' add another item to the collection
                Dim s As String = "New Item " & CStr(itemCount + 1)
                t.InvokeMember("Add", Reflection.BindingFlags.InvokeMethod, Nothing, value, New Object() {s}))

            End Set
        End Property

    End Class

End Namespace

("55555555-4444-3333-2222-111111111111"),>(1)>("11111111-2222-3333-4444-555555555555"),>