I have these codes that are supposed to load control arrays (days of week), there is only one textbox visible at design time, but I want to use control array to initialize the other six textboxes in order to display (Monday-Sunday) according to local system settings. But when I compile it only shows the error message and when i click OK, it then shows the form with the number "70" on it.
Please could anyone help me figure out what might be wrong and the solution? Thanks in advance
visual basic code:--------------------------------------------------------------------------------Private Sub Form_Load()
Call GetWeekDay
Call Update_Controls
End Sub
Private Function GetWeekDay()
On Error GoTo Error_Handle
Weekday(0) = WeekdayName(vbUseSystemDayOfWeek)
Weekday(1) = WeekdayName(vbTuesday)
Weekday(2) = WeekdayName(vbWednesday)
Weekday(3) = WeekdayName(vbThursday)
Weekday(4) = WeekdayName(vbFriday)
Weekday(5) = WeekdayName(vbSaturday)
Weekday(6) = WeekdayName(vbSunday)
Dim i As Integer
For i = 0 To 5
Load txtwkdayname(txtwkdayname.UBound + 1)
txtwkdayname(txtwkdayname.UBound).Top = (txtwkdayname(i).Top + txtwkdayname(i).Height) + 8
txtwkdayname(txtwkdayname.UBound).Visible = True
Next i
Error_Handle:
MsgBox "Please Check Your Codes"
End Function
Private Sub Update_Controls()
Dim i As Integer
For i = 0 To txtwkdayname.UBound
txtwkdayname(i).Text = Weekday(i) & i
Next i
End Sub--------------------------------------------------------------------------------
When I change the Error message from "Error handler to "On Error Reume Next" I got a diferent result:
Six extra txtboxes were added as I wanted, but then there were numbers from 7(the default textbox), 1,2...6. I wanted them to display, from Monday-Sunday in the local system form.
What should I do to correct this?
Also How Can I claculate and display lunch hours(in and Out)?