I haven't tried this, but it might work.
Create an import library for VB6's VBA6.dll. Create your own implementation of its _Collection interface. Use this implementation in place of the VBA.Collection class.
class MyCollection : VBA._Collection
{
private Dictionary<object, object> _items = new Dictionary<object, object>();
public void Add(ref object Item, [System.Runtime.InteropServices.OptionalAttribute]ref object Key, [System.Runtime.InteropServices.OptionalAttribute]ref object Before, [System.Runtime.InteropServices.OptionalAttribute]ref object After)
{
// Ignoring the Before and After params for simplicity
_items.Add(Key, Item);
}
public int Count()
{
return _items.Count;
}
public System.Collections.IEnumerator GetEnumerator()
{
return _items.Values.GetEnumerator();
}
public dynamic Item(ref object Index)
{
return _items[Index];
}
public void Remove(ref object Index)
{
_items.Remove(Index);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…