1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 4 - Working With Menus and Dialog Boxes - Part 2

By , About.com Guide

2 of 5

More on Date Data Types

VB.NET also uses a Date data type (just as Integer or String are data types, a Date data type is just a standard way of storing Date information in your program's memory). This data type is based on an international IEEE (Institute of Electrical and Electronics Engineers) standard. IEEE defines Date as a 64-bit (8-byte) integer that represents dates ranging from January 1 of the year 1 through December 31 of the year 9999, and times from 0:00:00 (midnight) through 11:59:59 PM. To use a Date value in your program, you have to enclose it in number signs (#) and it must be in the format m/d/yyyy . Using a method of the Date object called ToOADate, you can change ...

Dim mydate as Date
Dim mydatedbl As Double
mydate = #1/1/2000 12:00:00 PM#
mydatedbl = mydate.ToOADate

... into the same value that Excel calculates for this date and time. (OA in the method name ToOADate stands for Ole Automation - the technology that Excel uses.)

In addition, VB.NET also provides other functions for use in calculating with Date data type:

DATEDIFF( )
Calculates an interval between two dates.
DATEPART( )
Returns the specified portion of a date.
CURDATE( ), GETDATE( ) or DATE( )
Returns the current date in datetime format.

Now that we know what time it is, let's see if we can add a little color to our programming. But before reading the next page about that ...

--please complete the Using Dialog Box Control section of Chapter 4 now-----

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2009 About.com, a part of The New York Times Company.

All rights reserved.