I need to show the Leap year in visual basic, as well as calculate the Julian Date. I've got stuck on getting the results from the funtion into the label (my output component) I was just wondering if anyone could point me in the right direction![]()
VB Code:
Option Explicit Dim dayName(0 To 6), monDays(0 To 11) As String Private Sub cmdQuit_Click() End End Sub Private Sub Form_Load() dayName(0) = "Sunday" 'init day table dayName(1) = "Monday" dayName(2) = "Tuesday" dayName(3) = "Wednesday" dayName(4) = "Thursday" dayName(5) = "Friday" dayName(6) = "Saturday" monDays(0) = 31 monDays(1) = 4 monDays(2) = 31 monDays(3) = 30 monDays(4) = 31 monDays(5) = 30 monDays(6) = 31 monDays(7) = 31 monDays(8) = 30 monDays(9) = 31 monDays(10) = 30 monDays(11) = 31 End Sub Function dateName(dd, mm, ByVal yy As Integer) Dim d, c, m, y As Integer m = mm - 2 'oct = 8, Nov = 9 etc If m < 1 Then m = m + 12 yy = yy - 1 'of previous year End If y = yy Mod 100 c = (yy - y) \ 100 'Get century 'Now for Zeller's congruence .... 'add 700 in case -ve ' cast (convert) single values to integer d = (Int(2.6 * m - 0.2) + dd + y + Int(y \ 4) + Int(c \ 4) - (2 * c) + 700) Mod 7 dateName = dayName(d) End Function Function isLeapYear(year As Integer) Dim year As Boolean If (year Mod 4 = 0 And year Mod 100 <> 0) Or year Mod 400 = 0 Then Print "yes" Else Print "no" End If End Function Function showLeapYear(ByVal year As Integer) If isLeapYear = True Then lblLeap = "Yes" Else lblLeap = "No" End If End Function Private Sub txtYear_KeyPress(KeyAscii As Integer) Dim day, mon, year, leapYearShow As Integer Dim dayStr As String If KeyAscii = 13 Then day = Val(cboDay.Text) mon = cboMonth.ListIndex + 1 year = Val(txtYear) dayStr = dateName(day, mon, year) lblOutput = dayStr Call showLeapYear(year) End If End Sub
February has the Value "4" because I need to get the leap year validation script working before i can work out the number of days in february.
Thank you.
x


Reply With Quote


