Вернуть определенный пользователем тип данных в ячейку Excel

я искал в интернете и яя искал вопросы здесь на stackoverflow, но у меня нетЯ не смог найти решение.

Вот что яЯ хотел бы сделать:

Предположим, у меня есть следующий код в модуле класса с именем "Мои занятия"


Option Explicit
Dim var1 as integer<p></p>

<p>Sub Initialize(v as integer)
   var1 = v
End Sub</p>

Function GetVar1() GetVar1 = var1 End Function

Then I have a UDF in a separate module with the code

 
Function InitializeMyClass(v as integer) as MyClass
   Dim myvar as MyClass
   Set myvar = new MyClass
   Call myvar.Initialize(v)
   Set InitializeMyClass = myvar
End Function<p></p>

Function GetMyVar(m as MyClass) GetMyVar = m.GetVar1() End Function

Now in cell A1 I have "=InitializeMyClass(3)" and in Cell A2 I have "=GetMyVar(A1)". I get #VALUE errors in both cells. This of course is caused by the fact that I am trying to return a user defined data type into cell A1. I feel that this should be possible, but I am not sure how.

Edit: Oh yeah, the question is, "Is there a way for me to return a user-defined data type into a cell and then have it be callable from another UDF in the example I gave above? I don't know if this requires COM or not. If it does, anyone know how I can get started? Ideally, if someone had an example of how this worked, that would be fantastic!"

Another Edit: Here we go, now i know it can be done: read this description, it's not quantitative, but will give you a sense of what they do, http://www.quanttools.com/index.php?option=com_content&task=view&id=19

Ответы на вопрос(3)

Ваш ответ на вопрос