I’m new to programming in VBA, but what I’m trying to do right now is have a PowerPoint slide that updates every day. It’s a weather forecast slide that is displayed in our lobby, and currently I manually update the seven day forecast each day I come in. This means that until I come in, it shows the current day as yesterday’s date, and the seven day forecast is still showing yesterday’s date in the forecast. Ultimately I’d like to have it pull in the weather data automatically as well, but for the scope of this question, I’m just trying to figure out how to display the dates in a textbox for the seven days of the week.
Basically, there’s a header along the top with: (e.g. Wednesday, June 30, 2010)
Then the seven days set up in columns with: (e.g. June 30 July 1 July 2 …)
I would like to set the header to the current date as shown, and then the seven textboxes below to the current day, then tomorrow, then the next day… and so on until the seventh day.
How would I increment the DateTime? Thanks!
If you want to go forward in 1-day steps, you can increment DateTime variables by adding to them:
This works because internally, a DateTime is represented as a floating point number with whole days before the comma and fractions of days after the comma. (Consequently, adding 0.5 would effectively add 12 hours, though I would not recommend doing that.)
For more complex operations like adding months or hours, there is
DateAdd()(see MSDN).You can “add” negative values with
DateAdd(), too.