Sie sind auf Seite 1von 6

'--------------------------------------------------------------------------------------' Program : PeriodOfExistenceCalculator ' Instructor : Reynan Espinosa Demafeliz ' Date : 8/1/2013 ' Purpose : Determine the

period of one's existence through defined algorithm based on birthday '--------------------------------------------------------------------------------------Dim sirreynan As Boolean Dim Ownership As String Dim sksuIT Private Sub cboBirthDay_LostFocus() If cboBirthDay.Text = "" Then cboBirthDay.Text = "Date" End If End Sub Private Sub cboBirthDay_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cboBirthYear.SetFocus End If End Sub Private Sub cboBirthMonth_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cboBirthDay.SetFocus End If End Sub Private Sub cboBirthMonth_LostFocus() If cboBirthMonth.Text = "" Then cboBirthMonth.Text = "Month" End If End Sub Private Sub cboBirthDay_GotFocus() tmrCalculate.Enabled = False End Sub Private Sub cboBirthMonth_GotFocus() tmrCalculate.Enabled = False

End Sub Private Sub cboBirthYear_GotFocus() tmrCalculate.Enabled = False End Sub Private Sub cboBirthYear_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then tmrCalculate_Timer End If End Sub Private Sub cboBirthYear_LostFocus() If cboBirthYear.Text = "" Then cboBirthYear.Text = "Year" End If If Len(cboBirthYear.Text) < 4 Then MsgBox "Entsirreynan the Date in four digits", vbInformation, "Period of Existence Calculator" cboBirthYear.SetFocus End If If KeyAscii = 13 Then tmrCalculate_Timer End If End Sub Private Sub Command1_Click() Form2.Show End Sub Private Sub Form_Load() Ownership = "Program created by Reynan E. Demafeliz" sksuIT = 0 lblDay.Caption = "" lblMonth.Caption = "" lblYear.Caption = "" lblHour.Caption = "" lblMinute.Caption = "" lblSecond.Caption = "" lblDayBorn.Caption = ""

If App.PrevInstance Then MsgBox "Period of Existence Calculator is already running", vbInformation, "Period of Existence Calculator" End End If dat = Format(Date, "mmm/dd/yyyy") lblCurrentDay.Caption = "Current Date: " & dat lblCurrentTime.Caption = "Current Time: " & Time cboBirthDay.Text = "Date" For i = 1 To 31 cboBirthDay.AddItem i Next cboBirthMonth.Text = "Month" For i = 1 To 12 cboBirthMonth.AddItem i Next cboBirthYear.Text = "Year" For i = 1900 To Year(Date) cboBirthYear.AddItem i Next End Sub Private Sub tmrCalculate_Timer() sirreynan = False On Error GoTo aaa: BirthDay = cboBirthMonth.Text & "/" & cboBirthDay.Text & "/" & cboBirthYear.Text BornDay = DateDiff("d", Now, BirthDay) If BornDay <= 0 Then BornDay = -BornDay Else sirreynan = True End If mm = DateDiff("m", Now, BirthDay) If mm <= 0 Then mm = -mm Else

sirreynan = True End If If sirreynan = True Then GoTo aaa: lblDay.Caption = Str(BornDay) lblMonth.Caption = Str(mm) lblYear.Caption = Str(-DateDiff("yyyy", Now, BirthDay)) lblHour.Caption = Str(-DateDiff("h", Now, BirthDay)) lblMinute.Caption = Str(-DateDiff("n", Now, BirthDay)) lblSecond.Caption = -DateDiff("s", Now, BirthDay) tmrSecondController.Enabled = True lblDayBorn.Caption = DetectBornDay(Weekday(BirthDay)) Exit Sub aaa: MsgBox "Invalid Input", vbCritical, "Period of Existence Calculator" tmrCalculate.Enabled = False Exit Sub End Sub Private Function DetectBornDay(da As Integer) As String Select Case da Case 1 DetectBornDay = "Sunday" Case 2 DetectBornDay = "Monday" Case 3 DetectBornDay = "Tuesday" Case 4 DetectBornDay = "Wednesday" Case 5 DetectBornDay = "Thursday" Case 6 DetectBornDay = "Friday" Case 7 DetectBornDay = "Saturday" Case Else

MsgBox "Unknown error", vbInformation, "Period of Existence Calculator" End Select End Function Private Sub tmrCurrentTime_Timer() lblCurrentTime.Caption = "Current Time: " & Time End Sub Private Sub tmrSecondController_Timer() lblSecond.Caption = Val(lblSecond.Caption) + 1 End Sub Private Sub tmrZeroCode_Timer() tmrZeroCode.Interval = 50 sksuIT = sksuIT + 1 staZeroCode.Panels(1).Text = Left(Ownership, sksuIT) If sksuIT = Len(Ownership) Then sksuIT = 1 tmrZeroCode.Interval = 2000 End If End Sub

Das könnte Ihnen auch gefallen