Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I store more than one value at an array index?

Status
Not open for further replies.

Philly44

Programmer
Jul 17, 2001
277
CA
I would like to store 2 values in the same array index. I have to sum and to some calcutions on data that was entered by the hour. I need to sum these values for the day and use this value later in a calculation. THe problem I am running into is there are different formulas based on the day of the week. What I was thinking was store the sum for a day then store what day of the week it was.
ie: myarray(10,Sunday) 10 being the total and sunday being the day of the week. Is this even possible?

Thanks in advance
Chris
 
Hi Chris!

Try this:

In a module define:

Type DailySums
Total As Integer
DayOfWeek As String
End Type

Then to declare the array use:

Dim myarray() As DailySums

Now you can get to both elements using the dot operator:

myarray(1).Total = 10
myarray(1).DayOfWeek = "Sunday"

hth Jeff Bridgham
bridgham@purdue.edu
 
Thats look like it'll defenitly do it. It'll be a little while before I know for sure but I think thats it.

Thank you, you have saved me hours of work

CHris
 
Hi Philly44

Have you considered a collection rather than array. How about something like:

Code:
Dim colDayHourTotal as new Collection

colDayHourTotal.Add item := SumTotal, key := SomeDate
msgbox colDayHourTotal(SomeDate)

Don't forget to set the collection to nothing when finished.

Hope this helps,
Rewdee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top