From the course: Visual Basic Essential Training
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Define date and time variables - Visual Basic Tutorial
From the course: Visual Basic Essential Training
Define date and time variables
- [Instructor] Our first task in this chapter is how to declare variables of date types, so I've got four examples here. One is typed as Date, one is typed as DateTime, and the last two are DateOnly and TimeOnly. If you hover over the variables, you can see the type of that variable. The most important one to see here is that this one, even though I declared it as a DateTime, the editor here in Visual Studio thinks that is a Date, because as I said, this is an alias. Date is an alias for DateTime. The rest of the code is just printing out the values. Since I haven't initialized them yet, you'll see the default values. Click on this first button. So, at the top, you'll see the Date and DateTime both contain both of those portions, the date and the time. The default date is 1/1/0001, and the default time is 12:00 AM, and of course, you can see down here, the advantage of these two types is that they only have the date portion or the time portion. The next step is to initialize these so…
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
The date types2m 27s
-
(Locked)
Define date and time variables1m 6s
-
(Locked)
Initialize date and time values4m 42s
-
(Locked)
Output formatted date values3m 50s
-
(Locked)
Date manipulation2m 14s
-
(Locked)
Challenge: Strings, dates, and parsing1m 47s
-
(Locked)
Solution: Strings, dates, and parsing2m 22s
-
(Locked)
-
-
-
-
-
-
-
-
-
-