Date and Time Program in Visual Basic

with 1 Comment




Date and time program in visual basic is one of the main programs. To know about this program follow these steps.



How to Create a Program in VB to Display Date and Time?

Step 1: –

  • At first open Visual Basic 6.0 application software
  • Then click on or select ‘Standard EXE’ icon from New Project dialog box
  • Then click on ‘Open’.

Step 2: –

Form Design: –

Select necessary Control Tool from Tool Box and adjust position to ‘Form Window’: –

  • Two Label Box
  • Two Text Box
  • Four Command Box

Date and Time Program

Step 3: –

Properties Settings( Date and Time Program): –

  • Select ‘Form1’from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Form1’ to ‘Date and Time Project’ from properties window
  • Then select ‘Label1 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Label1’ to ‘Today’s Date is’ from Properties Window
  • Then select ‘Label 2 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Label 2’ to ‘Time is’ from Properties Window
  • Then select ‘Text1 box’ from Form Window and select ‘Text’ from Properties Window
  • Then remove or erase‘Text1’ from Properties Window
  • Then select ‘Text2 box’ from Form Window and select ‘Text’ from Properties Window
  • Then remove or erase‘Text2’ from Properties Window
  • Then select ‘Command1 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Command1’ to ‘DATE’ from Properties Window.
  • Then select ‘Command 2 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Command 2’ to ‘TIME’ from Properties Window.
  • Then select ‘Command 3 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Command 3’ to ‘CLEAR’ from Properties Window.
  • Then select ‘Command 4 box’ from Form Window and select ‘Caption’ from Properties Window
  • Then replace ‘Command 4’ to ‘QUIT’ from Properties Window.

date and time project
date-and-time-project

date-and-time-project

date-and-time-project

date-and-time-project

Step 4: –

Code Writing:-

  • Double click on ‘DATE button’ or ‘Command 1 box’
  • Then input code to Command 1 code box

Code: – Text1.Text = Date

              Label1.Visible = True

  • Then double click on ‘TIME button’ or ‘Command 2 box’
  • Then input code to Command 2 code box.

Code: – Text2.Text = Time

              Label2.Visible = True

  • Then double click on ‘CLEAR button’ or ‘Command 3 box’
  • Then input code to Command 3 code box.

Code: – Text1.text = “”

             Text2.text = “”

  • Then double click on ‘QUIT button’ or ‘Command 4 box’
  • Then input code to Command 4 code box.

Code: – End

date-and-time-project

  • Then close code box 

Step 5: –

  Project Save: –

  • Click on ‘Save project’ option from File menu
  • Then input any name to file name box and click on Save option from Save file as box
  • Then input any new name to file name box
  • Then click ‘Save’ option.

Step 6: –

Project Run: –

  • Press F5 key from keyboard or click on ‘Start’ from ‘Run menu’ for run the project
  • Then click on ‘DATE’ and ‘TIME’ for display Date and

Time to Text1 & Text2 .

date-and-time-project

  • Then click on ‘CLEAR Button’ for clear the Text1 & Text2 box.
  • Then click on ‘QUIT Button’ for the close the result window





Related Posts:

One Response

  1. Jinia
    | Reply

    nice sir..

Leave a Reply