在EXCEL VBA中调用C#dll - 如何访问列表项?

时间:2013-12-18 12:47:43

标签: c# excel vba excel-vba

我在c#中编写了类库(简化版):

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()
        {
            List<CPoint> result = new List<CPoint>();

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    result.Add(new CPoint(i, j));
                }
            }

            return result;
        }
    }
}

在VBA中的Excel中可以创建类CPoint的实例,如下所示:

Private Sub TestDotNetCall()
Dim pt As New CPoint
End Sub

如何调用方法'GetSomePoints'?如何在VBA中访问List的项目?

0 个答案:

没有答案