Hi
I have one array that lists a set of curency pairs in the form
AUDCAD
CADUSD
GBPUSD
A second array that lists some incremented times in the form
10:00
10:05
10:10
I would like to combine the first rows in each array into one item, the second rows into one item etc. so i can then search the new array for the pair and return the time.
If it could be a dictionary (which i have only just come across) it would allow easy selection I think.
The two existing arrays are shown below
Is there an easy way?
Thanks
Neil
Sub ReadTimesToArray(sStartTime, intNoOfTimes, intAddTime)
Dim MyFile As String
Dim strTimeValue As Date
Dim counter As Long
Dim sAddtime As String
' convert integer time to string time
sAddtime = Format(Int((intAddTime) Mod 60), "00:00")
'get the start time to use in the array and subtract increment time to allow every loop thereafter to be incremented.
strTimeValue = TimeValue(sStartTime) - TimeValue(sAddtime)
'Create a dynamic array variable, and then declare its initial size
ReDim TimeListArray(100)
'take the start time and stick it in the array then increment by sAddTime value
For counter = 0 To intNoOfTimes
TimeListArray(counter) = Left((TimeValue(strTimeValue) + TimeValue(sAddtime)), 5)
strTimeValue = TimeListArray(counter)
Next counter
'Reset the size of the array without losing its values by using Redim Preserve
ReDim Preserve TimeListArray(counter - 1)
'To prove it worked print the values stored
Dim cnt As Integer
For cnt = 0 To intNoOfTimes
'Debug.Print writes the results to the Immediate window (press Ctrl + G to view it)'
Debug.Print TimeListArray(cnt)
Next cnt
End Sub
Sub ListPairsToArray(strfolder)
Dim MyFile As String
Dim counter As Long
'Create a dynamic array variable, and then declare its initial size
ReDim CurrencyPairsArray(100)
'Loop through all the files in the directory by using Dir$ function
MyFile = Dir$(strfolder & "\*.tpl")
Do While MyFile <> ""
CurrencyPairsArray(counter) = Left(MyFile, 6)
MyFile = Dir$
counter = counter + 1
Loop
CurrencyPairsArray = RemoveDupes(CurrencyPairsArray)
'Reset the size of the array without losing its values by using Redim Preserve
ReDim Preserve DirectoryListArray(counter - 1)
For counter = 0 To UBound(CurrencyPairsArray)
Debug.Print CurrencyPairsArray(counter)
Next counter
End Sub
Bookmarks