Assigning values in an array...
-
I need some assistance with a small application. I need to loop through an existing array and to assign a value to it in a pattern. I thought that I could do it, but I am really at a loss as to how to proceed. I tried a wide variety of approaches but it does not yield the correct results. As a smaller scale version of the array. Let us say that the array consists of 392 elements. The first element of the array consists of date values from 12/30/2007 and it proceeds up until 1/24/2009. The second element should be number values from 1 to 13. The pattern is that there should be 28 values with the value 1, and then 28 values with the value 2, and then 28 values with the value of 3. This procedure continues with 28 values of the value 13. After the 28th value of 13, the numbering system should start over again with 28 values with the value of 1. This should populate all of the elements of the 392 element array. The code below that I have written, for some reason, does not include the 28th value for each of these assignments. Also, it includes a 14th value following the last 13 value assignment. Please provide me with some assistance! :confused::confused::confused:
Public Function ZodiacPeriod(dteInputDate)
Dim dteStart As Date
Dim dteEnd As Date
Dim intDateCount As Integer
Dim intRow As Integer
Dim intX As Integer
Dim intCounter As Integer
Dim arrArray(392, 1)intX = 1 dteStart = #12/30/2007# dteEnd = #1/24/2009# intDateCount = DateDiff("d", dteStart, dteEnd) 'Loading the array with dates For intRow = 1 To intDateCount arrArray(intRow, intColumn) = dteStart dteStart = dteStart + 1 Next 'The second element value is assigned here For intRow = 0 To 392 If intCounter <= 27 Then If intX >= 14 Then intX = 1 End If intCounter = intCounter + 1 Else intCounter = 1 If intX < 14 Then intX = intX + 1 End If End If arrArray(intRow, 1) = intX Next intRow 'Now to go through the array and return the value in the array For intRow = 0 To 392 If arrArray(intRow, 0) = dteInputDate Then ZodiacPeriod = arrArray(intRow, 1) Exit For End If Next intRow
End Function
I have encountered problems in which a value of 14 is assigned. I have encountered problems in which the requirements are not ma
-
I need some assistance with a small application. I need to loop through an existing array and to assign a value to it in a pattern. I thought that I could do it, but I am really at a loss as to how to proceed. I tried a wide variety of approaches but it does not yield the correct results. As a smaller scale version of the array. Let us say that the array consists of 392 elements. The first element of the array consists of date values from 12/30/2007 and it proceeds up until 1/24/2009. The second element should be number values from 1 to 13. The pattern is that there should be 28 values with the value 1, and then 28 values with the value 2, and then 28 values with the value of 3. This procedure continues with 28 values of the value 13. After the 28th value of 13, the numbering system should start over again with 28 values with the value of 1. This should populate all of the elements of the 392 element array. The code below that I have written, for some reason, does not include the 28th value for each of these assignments. Also, it includes a 14th value following the last 13 value assignment. Please provide me with some assistance! :confused::confused::confused:
Public Function ZodiacPeriod(dteInputDate)
Dim dteStart As Date
Dim dteEnd As Date
Dim intDateCount As Integer
Dim intRow As Integer
Dim intX As Integer
Dim intCounter As Integer
Dim arrArray(392, 1)intX = 1 dteStart = #12/30/2007# dteEnd = #1/24/2009# intDateCount = DateDiff("d", dteStart, dteEnd) 'Loading the array with dates For intRow = 1 To intDateCount arrArray(intRow, intColumn) = dteStart dteStart = dteStart + 1 Next 'The second element value is assigned here For intRow = 0 To 392 If intCounter <= 27 Then If intX >= 14 Then intX = 1 End If intCounter = intCounter + 1 Else intCounter = 1 If intX < 14 Then intX = intX + 1 End If End If arrArray(intRow, 1) = intX Next intRow 'Now to go through the array and return the value in the array For intRow = 0 To 392 If arrArray(intRow, 0) = dteInputDate Then ZodiacPeriod = arrArray(intRow, 1) Exit For End If Next intRow
End Function
I have encountered problems in which a value of 14 is assigned. I have encountered problems in which the requirements are not ma
Three points. 1. You fill the array with dates starting at index = 1, but with numbers starting at index = 0. Is this correct? 2. You could try something like
intRow = 0
For j = 1 to 13
for i = 1 to 28
intRow = intRow + 1
arrArray(intRow,1 ) = j
next i
next j3. Wrong forum - there is a VB one (though people tend to be VB6 hostile, and this looks like VB6 or VBA to me.) :)
Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis