The default format of the Date and Time in Visual Basic is not always acceptable. For example, the following Visual Basic code excerpt will display the current setting of the Date variable in a MessageBox: Dim dteAppointment As Date = # 1:02:00 PM# The simplest way to obtain the current setting of a Date variable is simply to reference the Date as you would any other variable, using the variable name. To set both the date and time: Dim dteAppointment As Date = # 1:02:00 PM#Īccessing the Date and Time in a Date Variable For example, to set the time to 1:02 PM: Dim dteAppointment As Date = #1:02:00 PM# For example to set the date to August 2, 2007: Dim dteAppointment As Date = #Ī Date variable may be set to a specific time using the format hh:mm:ss AM/PM. The Date value is initialized using a date string in the form mm/dd/yyyy encapsulated in hash (#) characters. For example the following Visual Basic code excerpt creates a Date variable: Dim dteAppointment As Date Creating and Initializing a Visual Basic DateĪ Visual Basic Date can be created in the same way any other variable is created.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |