martin2k

Home | Forums | VB6 | Games | Software | Directory | HTML | Wiki | Blog | Contact

Day Discoverer


 

Home

Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here

Contact


 

Program

The Day Discoverer program displays the day for any date that is entered.


vb_67_daydisc.zip
(2.65 KB)

This program uses the following ActiveX controls:

  • Microsoft Windows Common Controls-2 6.0 (SP6)

This project contains one Form, Daydisc:

Daydisc
Daydisc

This form contains four Label controls - Dt, Month, Year and Label1.  The Label Label1, has its Font set to Times New Roman (size 24) and is used to display the date.

For the Date and Month, there are two ComboBoxes - Text1 and Text2. Both have their Style property set to 2 - Dropdown List. The Text1 ComboBox has 01 - 31 entered into the List property and Text2 has 01 - 12 in its List property. There is one TextBox for the year - Text3. On the right of Text3, is an UpDown control called YearUD.

Daydisc

Daydisc contains the following code:

Private Sub getday()
Label1.Caption = Format("" & Text1.Text & "/" & Text2.Text & "/" & Text3.Text & "", "dddd")
End Sub

Private Sub Form_Load()
Text1.Text = Format(Date, "dd")
Text2.Text = Format(Date, "mm")
Text3.Text = Format(Date, "yyyy")
Label1.Caption = Format(Date, "dddd")
End Sub


Private Sub Text1_Click()
Call getday
End Sub


Private Sub Text2_Click()
Call getday
End Sub


Private Sub Text3_Change()
Call getday
End Sub


Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If Not IsNumeric(Text3.Text) Then Exit Sub
If KeyCode = vbKeyUp Then Text3.Text = Text3.Text + 1
If KeyCode = vbKeyDown Then Text3.Text = Text3.Text - 1
End Sub


Private Sub YearUD_UpClick()
If Not IsNumeric(Text3.Text) Then Exit Sub
Text3.Text = Text3.Text + 1
End Sub


Private Sub YearUD_downClick()
If Not IsNumeric(Text3.Text) Then Exit Sub
Text3.Text = Text3.Text - 1
End Sub

When the program loads, the date is set to today's date, which subsequently shows today's day name.  Changing Text1, Text2 and Text3 activates the getday subroutine, which displays the day name for the date displayed.  In Text3_KeyDown, pressing the up or down arrow keys adds or subtracts 1 year from the year displayed.  This is also achieved with the YearUD_UpClick and YearUD_downClick events.


blog comments powered by Disqus
Martin Allen 1999 - 2011.  Last updated Saturday 13 August 2011 12:13:44 AM +0100.