Ad space (banner)
๐Ÿ”ทVB.NET Lessons
Lesson 36 / 68

Assembling and displaying a date

This lesson covers handling dates in VB.NET, with the aim of assembling a date and finding its day of the week.

The Date type handles dates and days of the week. New Date(year, month, day) creates one, and ToString() converts it into whatever text format you want.

The sample code builds a date with New Date(2026, 8, 9) and converts it to a display format with d.ToString(...). Note how d.DayOfWeek gets the weekday and combines it with an array of weekday names.

A common early stumble is that months and days count from 1, and the format-string syntax. The text you pass to ToString() changes the output, so you have to look up the specifier that suits your purpose.

In professional work, dates are needed in almost every application — showing when something was posted, calculating a deadline, branching by day of the week.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run VB.NET directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)