crustycollins
MIS
Ok, I have been working on this for a couple of days... I am new to doing this kind of thing in VBA so it may be a bit messy.
I get live data through DDE. I want to save the previous number and display is no matter what the current number is. This was easy when I only had one price ( only looking for the 2year bid) when I try and apply the same thing to multiple fields they step all over each other. It was obvious that I was overwriting the slot in the array with the new data... IF I could define the array with a variable in the function this would solve my whole problem... I CAN NOT FIGURE OUT HOW TO DO THAT!!!
Any suggestions?
Here is the code.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Public Static Function prevPrice(inputvalue As String)
Application.Volatile
Dim price(16) As String
Dim R As Integer
If inputvalue = "0" Or inputvalue = "" Then ' do not pub 0
Exit Function
End If
If price(R) <> inputvalue Then ' do not pub dups
price(R + 1) = price(R) ' move last one
Else
Exit Function
End If
prevPrice = price(R + 1) ' pub the prev price
price(R) = inputvalue ' reset for next iteration
End Function
I get live data through DDE. I want to save the previous number and display is no matter what the current number is. This was easy when I only had one price ( only looking for the 2year bid) when I try and apply the same thing to multiple fields they step all over each other. It was obvious that I was overwriting the slot in the array with the new data... IF I could define the array with a variable in the function this would solve my whole problem... I CAN NOT FIGURE OUT HOW TO DO THAT!!!
Any suggestions?
Here is the code.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Public Static Function prevPrice(inputvalue As String)
Application.Volatile
Dim price(16) As String
Dim R As Integer
If inputvalue = "0" Or inputvalue = "" Then ' do not pub 0
Exit Function
End If
If price(R) <> inputvalue Then ' do not pub dups
price(R + 1) = price(R) ' move last one
Else
Exit Function
End If
prevPrice = price(R + 1) ' pub the prev price
price(R) = inputvalue ' reset for next iteration
End Function