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!

Array required for hourly segments going back seven days.

Status
Not open for further replies.

BadCam

Technical User
Aug 24, 2007
2
NZ
Hi Tek-Tips people

The last time I tried any VB was back just before the turn of the century. I was pretty good at automating excel spreadsheets, but that's as far as my knowledge goes. I can have a go at doing this myself as long as I could just get some help on how to set up the array. I don't mind fumbling through trying to get it running. After all, how else can I learn do this better myself? Please let me know if perhaps I should break this question down into seperate threads. I can always come back here when I'm stuck. Thanks.

I'm not sure how best to explain what I require, but here goes:

I need an array (I assume) that can store the last seven days broken up into hour segments. I intend to use this array with a dropdown menu in an .hta form. I basically want to replicate the table which is from this website.


It changes every hour. The intention is to allow the user (ME :) ) to select any particular hour(s) and my program will download that hour(s) selected.

The array will store the following information:

Each of the last seven days including today

The day for each of the last seven days including today - Format Mon, Tue, Wed ...

The month associated with the last seven days (bearing in mind that there may have been a change of month in the previous seven days) - Format Jan, Feb, Mar...

The hours for each of the last seven days except that the last (or first?) hour will be this current hour less one. - Format 00.00, 01.00, 02.00, 03.00...

ie it's 9.04PM as I write this, but the array will store each hour for the last seven days starting (or ending?) at 8PM.

How can I display this in the form of a list with the ability to select any or all of the hourly segments?

The list would look like this (assuming today is Friday):

Sat, Aug, 11, 00.00
Sat, Aug, 11, 01.00
Sat, Aug, 11, 02.00
...
...
...

Fri, Aug, 17, 14.00
Fri, Aug, 17, 15.00
Fri, Aug, 17, 16.00

Have I explained this clearly enough? Please help. I believe I can do the rest of what I need, but this has me stumped.

Thanks very much in advance.
 
There's probably an easier way and this isn't taking into consideration the hours logic you mentioned, but may help get you closer.

Code:
Option Explicit

Dim intDTCount, dt1, intHrs
For intDTCount = -7 To 0
	dt1 = Now + intDTCount
	For intHrs = 0 To 23
		WScript.Echo WeekdayName(Weekday(dt1), True) & ", " & _
					 MonthName(Month(dt1), True) & ", " & _
					 Day(dt1) & ", " & Right("00" & intHrs, 2) & ".00"
	Next
Next

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Hi dm4ever

Thanks ever so much for your response. This looks to be just what I need. At least, I think it is. Please give me time to digest this first. Thank you anyway. This looks great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top