Sunday, October 18, 2020

Leap Year in Visual Basic

 A simple program that I wrote using Visual Basic 6 to ask the user to give a starting year and ending year and then the program will generate the list of years based on the given starting and ending years of the user.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.


Program Listing

Option Explicit

Public Function IsLeapYear0(ByVal y As Integer) As Boolean
    On Error Resume Next
    IsLeapYear0 = False
    'If the year is evenly divisible by 4 and not by 100, then this
    'is a leap year.
    If y Mod 4 = 0 And y Mod 100 <> 0 Then
        IsLeapYear0 = True
        'If the year is evenly divisible by 4 and 100, then check to
        'see if the quotient of year divided by 100 is also evenly
        'divisible by 4. If it is, then this is a leap year.
    ElseIf y Mod 4 = 0 And y Mod 100 = 0 Then
        If (y \ 100) Mod 4 = 0 Then IsLeapYear0 = True
    End If
End Function


Private Sub Command1_Click()
Dim y As Integer

    For y = Val(Text1.Text) To Val(Text2.Text)
        If IsLeapYear0(y) Then lstLeapYears(0).AddItem y
    Next y
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
lstLeapYears(0).Clear
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub


No comments:

Post a Comment