All pastes #99879 Raw Edit

MJ-12

public text v1 · immutable
#99879 ·published 2006-07-25 19:16 UTC
rendered paste body
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click

        Const decSalary As Decimal = 18.0 'Salary of labor per hour.
        Dim decPaintPrice As Decimal 'Price per gallon of paint
        'Dim sngLaborHours As Single 'Total hours needed to paint
        Dim decTotalPaintCost As Decimal 'Total cost for all the paint
        Dim decTotalLaborCost As Decimal 'Total price of labor
        Dim decTotal As Decimal 'Total price of the job

        decPaintPrice = CDec(txtPaintPrice.Text)
        'sngLaborHours = CSng(lblLaborHours.Text)
        'sngLaborHours = LaborHours(lblLaborHours.Text)

        lblLaborCost.Text = FormatCurrency(decTotalLaborCost)
        lblPaintCost.Text = FormatCurrency(decTotalPaintCost)
        lblTotal.Text = FormatCurrency(decTotal)

        decTotalPaintCost = PaintGallons() * decPaintPrice 'Total cost for paint.
        decTotalLaborCost = LaborHours() * decSalary 'Total cost for labor.
        decTotal = TotalLaborCost() + TotalPaintCost() 'Total cost for job.
    End Sub

    Function PaintGallons()
        'This function is to add the area and divide it by 115
        Const sngSQF As Single = 115 'Const 115 sq/ft of wall space is one gallon of paint
        Dim sngArea As Single 'To hold the area.
        Dim intRooms As Integer 'Number of rooms needed to be painted
        Dim intCount As Integer 'Loop Count
        Dim sngTotalArea As Single 'Use as an accumulator
        Dim strInput As String 'To get the area input
        'Dim sngPaintGallons As Single 'Gallons of paint required.
        'sngPaintGallons = CSng(lblPaintGallons.Text)
        intRooms = CInt(txtRooms.Text)
        intCount = 1
        sngTotalArea = 0

        ' Following loop gets the area of each room.
        Do While intCount <= intRooms
            strInput = InputBox("Enter the area of room " & intCount.ToString, "Input Needed")
            If strInput <> "" Then
                sngArea = CInt(strInput)
                sngTotalArea += sngArea
                intCount += 1
            End If
        Loop

        '    lblPaintGallons.Text = sngTotalArea / sngSQF
        Return sngTotalArea / sngSQF
    End Function
    Function LaborHours()
        Dim sngPaintGallons As Single 'Gallons of paint required.
        'sngPaintGallons = CSng(lblPaintGallons.Text)
        Const intHours As Integer = 8 'Const 8 hours of labor required per gallon of paint.
        Return sngPaintGallons * intHours
    End Function
    Function TotalLaborCost()
        Const decSalary As Decimal = 18.0 'Salary of labor per hour.
        Dim sngLaborHours As Single 'Total hours needed to paint
        Return sngLaborHours * decSalary 'Total cost for labor.
    End Function
    Function TotalPaintCost()
        Dim sngPaintGallons As Single
        Dim decPaintPrice As Decimal 'Price per gallon of paint
        Return sngPaintGallons * decPaintPrice 'Total cost for paint.
    End Function
    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ' This reset the controls to default values.
        ResetEntries()
        ResetPrice()
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        ' End the application
        Me.Close()
    End Sub
    Sub ResetEntries()
        'This resets entries in the form.
        txtRooms.Text = String.Empty
        txtPaintPrice.Text = String.Empty
    End Sub
    Sub ResetPrice()
        ' Reset lables.
        lblPaintGallons.Text = String.Empty
        lblLaborHours.Text = String.Empty
        lblPaintCost.Text = String.Empty
        lblLaborCost.Text = String.Empty
        lblTotal.Text = String.Empty
    End Sub
End Class