Trying to learn VB.NET, I have a question about the following code:
Public Class WageCalculatorForm
'handles Click event
Private Sub calculateButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles calculateButton.Click
'declare variables
Dim hours As Double
Dim wage As Decimal
Dim earnings As Decimal
Const HOUR_LIMIT As Integer = 40 'declare constant
'assign values from user input
hours = Val(hoursTextBox.Text)
wage = Val(wageTextBox.Text)
'determine wage amount
If hours <= HOUR_LIMIT Then
'if under or equal to 40 hours, regular wages
earnings = hours * wage
Else
'if over 40 hours, regular wages for first 40
earnings = HOUR_LIMIT * wage
'time and a half for the additional hours
earnings += (hours - HOUR_LIMIT) * (1.5 * wage)
End If
'assign the result to its corresponding Label
earningsResultLabel.Text = earnings
End Sub
End Class ' WageCalculatorForm
Why couldn't
earningsResultLabel.Text = earnings
be put under
'assign values from user input
hours = Val(hoursTextBox.Text)
wage = Val(wageTextBox.Text)
as
earnings = Val(earningsResultLabel.Text)
?