
1069 Information from the Web
Points of note:
•
The VBA function IsDate returns TRUE if its argument is or can be
converted to a Date Value; see appendix 1 for a full description.
•
The VBA functions Day, Month, and Year return the appropriate part
of their argument as a number; see appendix 1 for a full description.
•
The variable Title used in the call to InputBox is defi ned as a global
constant at the beginning of the module; it is going to be used as the title
of all the input and message boxes in the application. Here is the defi ni-
tion line:
Dim SY ‘ start year
‘Ask for a date; use current date as a default
Temp = InputBox(p, Title, Date)
‘Did we get the correct answer?
‘If so, use its date value; if not, use current
‘date value
If IsDate(Temp) Then
Temp = DateValue(Temp)
Else
Temp = Date
End If
‘Compute end and start day, month, and year;
‘Start date is 30 days before end date
ED = Day(Temp)
EM = Month(Temp) - 1 ‘ Yahoo month is 0-11
EY = Year(Temp)
SD = Day(Temp - 30)
SM = Month(Temp - 30) - 1 ‘ Yahoo month is 0-11
SY = Year(Temp - 30)
‘Compile the result string from the parameters
GetDates = “a=” & SM & “&b=” & SD _
& “&c” & SY & “&d=” & EM & “&e=” _
& ED & “&f” & EY & “&”
End Function