Adding Functions and Subroutines
From some reading, I know that two pieces of data may cause me problems. Each event log entry has a date and time associated with it, and WMI returns those with kind of a funny format. I need to take what WMI gives me and reformat it into normal-looking dates and times. I may as well create some functions to handle the reformatting.
Function CDateWMI(cim_DateTime)
'declare variables
Dim sDateTime, iYear, iMonth, iDay
'convert the date to a string
sDateTime = CStr(cim_DateTime)
'get the year, month, and day
iYear = CInt(Mid(sDateTime, 1, 4))
iMonth = CInt(Mid(sDateTime, 5, 2))
iDay = CInt(Mid(sDateTime, 7, 2))
'reformat into a normal date
CDateWMI = CDate(Join(Array(iMonth, iDay, iYear), "/"))
End Function
Function CTimeWMI(cim_DateTime)
'declare variables
Dim sDateTime, iHours, iMinutes, iSeconds
'convert the time into a string
sDateTime = CStr(cim_DateTime)
'get the hours, minutes, and seconds
iHours = CInt(Mid(sDateTime, 9, 2))
iMinutes = CInt(Mid(sDateTime, 11, 2))
iSeconds = CInt(Mid(sDateTime, 13, 2))
'reformat into a normal time
CTimeWMI = TimeSerial(iHours, iMinutes, iSeconds)
End Function
NOTE
I'll provide my usual line-by-line walk-through of these functions toward the end of this chapter.
So far, I have two or three files: the basic input form HTML, the prototype table HTML, and a third file containing my functions. I should be ready to start writing the main portion of the script.
|