|
-
Sep 27th, 2010, 07:40 AM
#1
Thread Starter
New Member
Strange lag when using classes
Hi,
I'm experiencing a strange lag when I create a simple class structure. I have an instrument class (which is essentially a dictionary of fields and values) and an instrumentbag class (which is basically a dictionary of instruments). When I test it, I get a strange lag. It only displays the second to last change and not the latest value. That is, if a value is 1 and then I change it to first 2 then 3, the value shown by the testGet function is 2. Has anyone else experienced this?
Public iBag As InstrumentBag
Function testSet(Name As String, Fields As Range, Values As Range) As Variant
Application.Volatile (True)
If (iBag Is Nothing) Then
Set iBag = New InstrumentBag
End If
If (Fields.Count = Values.Count) And (Fields.Rows.Count = Values.Rows.Count) And (Fields.Columns.Count = Values.Columns.Count) Then
Dim r As Integer
Dim c As Integer
For r = 1 To Fields.Rows.Count
For c = 1 To Fields.Columns.Count
iBag.Data(Name, Fields(r, c)) = Values(r, c)
Next c
Next r
End If
testSet = Now
End Function
Function testGet(Name As String, Fields As Range, TimeStamp As Variant) As Variant
Application.Volatile (True)
If (iBag Is Nothing) Then
Set iBag = New InstrumentBag
End If
Dim svar() As Variant
ReDim svar(Fields.Rows.Count, Fields.Columns.Count)
Dim r As Integer
Dim c As Integer
For r = 1 To Fields.Rows.Count
For c = 1 To Fields.Columns.Count
svar(r, c) = iBag.Data(Name, Fields(r, c))
Next c
Next r
testGet = svar
End Function
FYI, I did the same in a .NET xll and got the same behaviour, but not allways. I think it's related to the creation/calculation order.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|