Good afternoon folks,
I hoping someone may be able to offer some assistance in improving the code I have written to calculate holiday entitlement. The code works fine, it's just that I'm not sure it's the most efficient way of writing it, so any one could spear a moment to look over my code and let me have their view and or suggestions it would be most appreciated.
The code is placed in the on current event of my form.
I'm the most proficient in code writing, so please bear with me if I come back to you with clarification of any suggestions. thanks in advance the code is below:
===============
START CODE
===============
Const HolEntMon As Double = 1.83 'Declares the HolEntMon variable as a constant value of 1.83
Const HolHours44 As Double = 4.4 'Declares the HolHours44 as a constant value of 4.4
Const WorkDay As Integer = 5 'Declares the WorkDay variable as a constant value of 5
Const MonthsPerYear As Integer = 12 'Declares the MonthsPerYear variable as a constant value of 12
Const AnnualHoldays As Integer = 22 'Declares the AnnualHolidays variable as a constant value of 22
'Calculates the individuals Holiday entitlement in days according to the number of days worked
'per week.
'If the individual works 7 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
If Me![txtNumberOfWeeklyWorkDays] = 7 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 6 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 6 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 5 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 5 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 4 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.ElseIf Me![txtNumberOfWeeklyWorkDays] = 4 Then
ElseIf Me![txtNumberOfWeeklyWorkDays] = 4 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 3 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 3 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 2 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 2 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 1 day a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 1 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
End If
===============
END CODE
===============
cheers
John
I hoping someone may be able to offer some assistance in improving the code I have written to calculate holiday entitlement. The code works fine, it's just that I'm not sure it's the most efficient way of writing it, so any one could spear a moment to look over my code and let me have their view and or suggestions it would be most appreciated.
The code is placed in the on current event of my form.
I'm the most proficient in code writing, so please bear with me if I come back to you with clarification of any suggestions. thanks in advance the code is below:
===============
START CODE
===============
Const HolEntMon As Double = 1.83 'Declares the HolEntMon variable as a constant value of 1.83
Const HolHours44 As Double = 4.4 'Declares the HolHours44 as a constant value of 4.4
Const WorkDay As Integer = 5 'Declares the WorkDay variable as a constant value of 5
Const MonthsPerYear As Integer = 12 'Declares the MonthsPerYear variable as a constant value of 12
Const AnnualHoldays As Integer = 22 'Declares the AnnualHolidays variable as a constant value of 22
'Calculates the individuals Holiday entitlement in days according to the number of days worked
'per week.
'If the individual works 7 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
If Me![txtNumberOfWeeklyWorkDays] = 7 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 6 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 6 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 5 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 5 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 4 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.ElseIf Me![txtNumberOfWeeklyWorkDays] = 4 Then
ElseIf Me![txtNumberOfWeeklyWorkDays] = 4 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 3 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 3 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 2 days a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 2 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
'If the individual works 1 day a week then calculate the HolEntMon [1.83]/Workday [5] *
'the number of days worked per week [txtNumberOfWeeklyWorkDays]* MonthsPeryear [12]and
'assign the result to the [txtHolsEntDays] text box.
ElseIf Me![txtNumberOfWeeklyWorkDays] = 1 Then
Me![txtHolsEntDays] = HolEntMon / WorkDay * Me![txtNumberOfWeeklyWorkDays] * MonthsPerYear
End If
===============
END CODE
===============
cheers
John