O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

TimeString Property

Class

Microsoft.VisualBasic.DateAndTime

Syntax

TimeString(  )

Return Value

String representing the current system time

Description

Returns or sets the current system time

Rules at a Glance

  • The TimeString property returns the time in the format determined by the system’s regional settings.

  • You can use any time format recognized by IsDate when setting the time using the TimeString property.

Programming Tips and Gotchas

  • The string returned by the TimeString property also includes an invalid date, 01/01/0001. It can be eliminated with the Format or FormatDateTime function as follows:

    Format(TimeOfDay(  ), "Long Time")
    FormatDateTime(TimeOfDay(  ), DateFormat.LongTime)
  • To get or set the current system date as a String, use the DateString property.

  • To access the current system time as a Date, use the TimeOfDay property.

VB.NET/VB 6 Differences

The TimeString property is new to VB.NET.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required