post
poster: toraton
description: Function example in VB
language: Visual Basic
[download]
1
2
3
4
5
6
7
8
9
10
11
12
13
Private Function CalculateGrossPay(hours as Double, pay as Double)
    If hours <= 40 Then
        CalculateGrossPay = pay * hours
    Else
        CalculateGrossPay = pay * 40 + 1.5 * pay * (hours - 40)
    End If
End Function

Private Sub btnCalculate_Click() Handles btnCalculate.Click
    total = CalculateGrossPay(txtHoursWorked.Text, txtHourlyPay.Text)
    btnOutput.Text = "You get paid " & FormatCurrency(total) & "."
End Sub