Consulting

Results 1 to 2 of 2

Thread: Get list<T> from c# dll and access to its items

  1. #1
    VBAX Newbie
    Joined
    Dec 2013
    Posts
    1
    Location

    Get list<T> from c# dll and access to its items

    Hello everyone!
    I wrote class library in c# like this (simplified):

    namespace DotNetLibrary
    {
        public class CPoint
        {
            public int x;
            public int y;
    
            public CPoint(int x, int y)
            {
                this.x = x;
                this.y = y;
            }
    
            public List<CPoint> GetSomePoints(int i_max, int j_max)
            {
                List<CPoint> result = new List<CPoint>();
    
                for (int i = 0; i <= i_max; i++)
                {
                    for (int j = 0; j <= j_max; j++)
                    {
                        result.Add(new CPoint(i, j));
                    }
                }
    
                return result;
            }
        }
    }
    In Excel in VBA I can create instance of class CPoint like this:

    Private Sub TestDotNetCall()
    Dim pt As New CPoint(100, 100)
    End Sub
    Can you please help me, how can I call method 'GetSomePoints' in VBA? And how can I access to the items of the List in VBA?

    Thanks,
    Pavel
    Last edited by pavel; 12-20-2013 at 09:30 AM.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Read through this thread for an example though my example is in vb.net.
    http://www.vbaexpress.com/forum/show...t-return-value

    You could post the DLL I guess and show some sample input and output. Keep in mind that I am not too "sharp".

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •