Here I have an assignment statement:
ThisYear.Item(j).Jan.Wkx_HrBlk1 = GetHrBlocksPerMonth(HRBLK1)
Jan corresponds to the month January. Is there any way to insert a variable in place of Jan, which can also assume Feb, Mar, Apr, etc. if assigned to do so?
Class Structure Below
Public Class Year
'Generate Data For Each Year
Public CurrentYear As UInt16 'Holds Current Year Value
Public TotalImages As UInt16 'Total Images collected on a yearly basis
Public JanTotals As UInt16 'Image Totals for the Month Of Jan
Public FebTotals As UInt16 ' Etc
Public MarTotals As UInt16
Public AprTotals As UInt16
Public MayTotals As UInt16
Public JunTotals As UInt16
Public JulTotals As UInt16
Public AugTotals As UInt16
Public SepTotals As UInt16
Public OctTotals As UInt16
Public NovTotals As UInt16
Public DecTotals As UInt16
'Subclass of Year are Months
Public Jan As New Month
Public Feb As New Month
Public Mar As New Month
Public Apr As New Month
Public May As New Month
Public Jun As New Month
Public Jul As New Month
Public Aug As New Month
Public Sep As New Month
Public Oct As New Month
Public Nov As New Month
Public Dec As New Month
Public Class Month
Public Wk1 As New Week
Public Wk2 As New Week
Public Wk3 As New Week
Public Wk4 As New Week
Public Wk5 As New Week
Public Wkx_HrBlk1 As UInt16
Public Wkx_HrBlk2 As UInt16
Public Wkx_HrBlk3 As UInt16
Public Wkx_HrBlk4 As UInt16
Public Wkx_HrBlk5 As UInt16
Public Wkx_HrBlk6 As UInt16
Public Wkx_HrBlk7 As UInt16
Public Wkx_HrBlk8 As UInt16
Public Wkx_HrBlk9 As UInt16
Public Wkx_HrBlk10 As UInt16
Public Wkx_HrBlk11 As UInt16
Public Wkx_HrBlk12 As UInt16
Public Class Week
Public HrBlk1 As UInt16
Public HrBlk2 As UInt16
Public HrBlk3 As UInt16
Public HrBlk4 As UInt16
Public HrBlk5 As UInt16
Public HrBlk6 As UInt16
Public HrBlk7 As UInt16
Public HrBlk8 As UInt16
Public HrBlk9 As UInt16
Public HrBlk10 As UInt16
Public HrBlk11 As UInt16
Public HrBlk12 As UInt16
End Class
End Class
End Class
***
Also, I also have an enumeration which mirrors the structure for month. Is there any way to leverage the Enumeration?
Public Enum MonthEnum
Dec = 0
Jan = 1
Feb = 2
Mar = 3
Apr = 4
May = 5
Jun = 6
Jul = 7
Aug = 8
Sep = 9
Oct = 10
Nov = 11
End Enum
Here is the context for the assignment statement. Note that k variable references the Month so I would like to use this variable to point to the certain class structure.
'Generate Totals for Each Month
For k = 0 To 11 'k refers to Months
WM = k
GetMonths(k) = (From Row As DataRow In dt.Rows Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Year = WY _
Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Month = WM _
Select Row.Field(Of UInteger)("HRBlk1")).Count 'Can Refer to a random Column. Will count all rows irrespective of value
For p = 0 To 11 'p refers to Hour Blocks
TempString = "HrBlk" & CStr(p + 1)
GetHrBlocksPerMonth(p) = (From Row As DataRow In dt.Rows Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Year = WY _
Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Month = WM _
Select Row.Field(Of UInteger)(TempString)).Sum(Function(ThisRow) ThisRow) 'Break down of Hour Blocks by Year.
Next
Select Case k
'Assigments mapping k to Class identifier would go here
End Select
ThisYear.Item(j).Jan.Wkx_HrBlk1 = GetHrBlocksPerMonth(HrBlkEnum.HrBlk1)
Next
ThisYear.Item(j).Jan.Wkx_HrBlk1 = GetHrBlocksPerMonth(HRBLK1)
Jan corresponds to the month January. Is there any way to insert a variable in place of Jan, which can also assume Feb, Mar, Apr, etc. if assigned to do so?
Class Structure Below
Public Class Year
'Generate Data For Each Year
Public CurrentYear As UInt16 'Holds Current Year Value
Public TotalImages As UInt16 'Total Images collected on a yearly basis
Public JanTotals As UInt16 'Image Totals for the Month Of Jan
Public FebTotals As UInt16 ' Etc
Public MarTotals As UInt16
Public AprTotals As UInt16
Public MayTotals As UInt16
Public JunTotals As UInt16
Public JulTotals As UInt16
Public AugTotals As UInt16
Public SepTotals As UInt16
Public OctTotals As UInt16
Public NovTotals As UInt16
Public DecTotals As UInt16
'Subclass of Year are Months
Public Jan As New Month
Public Feb As New Month
Public Mar As New Month
Public Apr As New Month
Public May As New Month
Public Jun As New Month
Public Jul As New Month
Public Aug As New Month
Public Sep As New Month
Public Oct As New Month
Public Nov As New Month
Public Dec As New Month
Public Class Month
Public Wk1 As New Week
Public Wk2 As New Week
Public Wk3 As New Week
Public Wk4 As New Week
Public Wk5 As New Week
Public Wkx_HrBlk1 As UInt16
Public Wkx_HrBlk2 As UInt16
Public Wkx_HrBlk3 As UInt16
Public Wkx_HrBlk4 As UInt16
Public Wkx_HrBlk5 As UInt16
Public Wkx_HrBlk6 As UInt16
Public Wkx_HrBlk7 As UInt16
Public Wkx_HrBlk8 As UInt16
Public Wkx_HrBlk9 As UInt16
Public Wkx_HrBlk10 As UInt16
Public Wkx_HrBlk11 As UInt16
Public Wkx_HrBlk12 As UInt16
Public Class Week
Public HrBlk1 As UInt16
Public HrBlk2 As UInt16
Public HrBlk3 As UInt16
Public HrBlk4 As UInt16
Public HrBlk5 As UInt16
Public HrBlk6 As UInt16
Public HrBlk7 As UInt16
Public HrBlk8 As UInt16
Public HrBlk9 As UInt16
Public HrBlk10 As UInt16
Public HrBlk11 As UInt16
Public HrBlk12 As UInt16
End Class
End Class
End Class
***
Also, I also have an enumeration which mirrors the structure for month. Is there any way to leverage the Enumeration?
Public Enum MonthEnum
Dec = 0
Jan = 1
Feb = 2
Mar = 3
Apr = 4
May = 5
Jun = 6
Jul = 7
Aug = 8
Sep = 9
Oct = 10
Nov = 11
End Enum
Here is the context for the assignment statement. Note that k variable references the Month so I would like to use this variable to point to the certain class structure.
'Generate Totals for Each Month
For k = 0 To 11 'k refers to Months
WM = k
GetMonths(k) = (From Row As DataRow In dt.Rows Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Year = WY _
Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Month = WM _
Select Row.Field(Of UInteger)("HRBlk1")).Count 'Can Refer to a random Column. Will count all rows irrespective of value
For p = 0 To 11 'p refers to Hour Blocks
TempString = "HrBlk" & CStr(p + 1)
GetHrBlocksPerMonth(p) = (From Row As DataRow In dt.Rows Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Year = WY _
Where Date.ParseExact(Row.Item("Date"), "yyyy:MM:dd", Nothing).Month = WM _
Select Row.Field(Of UInteger)(TempString)).Sum(Function(ThisRow) ThisRow) 'Break down of Hour Blocks by Year.
Next
Select Case k
'Assigments mapping k to Class identifier would go here
End Select
ThisYear.Item(j).Jan.Wkx_HrBlk1 = GetHrBlocksPerMonth(HrBlkEnum.HrBlk1)
Next
Last edited: