我相信这是一个艰难的...变量绑定类
我想创建一个类的变量绑定的集合。
它的目的是这个样子:
Dim x as integer, s as string
Dim c as new VBindClass
x = 1
s = "Hello"
c.Add x, s
Debug.Print c.value(x) '= 1
Debug.Print c.value(s) '= "Hello"
有一些功能,使我们能够取得一个唯一的ID为给定的变量,还可以获得基于可变/套?
更新:
最后,我已经成功地找到了答案。下面的代码:
Dim gh As Runtime.InteropServices.GCHandle = Runtime.InteropServices.GCHandle.Alloc(obj)
Return Runtime.InteropServices.GCHandle.ToIntPtr(gh).ToInt64
是否有其他人无法理解这一点? – ChaosPandion 2010-04-15 03:06:09