I assume you are talking about Excel VBA in C # ...
here's the minimal C # class that does this in the default project name ClassLibrary1:
using System;
using System.Runtime.InteropServices;
namespace Tester
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class TestClass
{
public double D { get; set; }
public string S { get; set; }
}
}
and here is VBA to try the class:
Private Sub foo()
Dim X As New ClassLibrary1.TestClass
X.S = "Hello"
Debug.Print X.S ' prints "hello"
X.D = 12
Debug.Print X.D ' prints a 12
End Sub
and here are the extra things you need to do to make this work:
(1) in C
(2) in C
check "Make assembly COM-visible"
(3) in VBA ... Tools ... References, browse to the C
. , . , VBA "" w, . VB .NET, (, ) . , "" - , ... , . ( ) . TestClass, , , AutoDual , () VBA ( Intellisense).
, .