Option Strict On Public Class Form1 'Const 115 sq/ft of wall space is one gallon of paint. Const sngSQF As Single = 115S 'Salary of labor per hour. Const sngSalary As Single = 18.0 'Const 8 hours of labor required per gallon of paint. Const intHours As Integer = 8 Dim sngTotalArea_ As Single = 0 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click 'Prevents nothing being entered on the lables. If IsNumeric(txtRooms.Text) = False Or IsNumeric(txtPaintPrice.Text) = False Then MessageBox.Show("Please enter a integer. No text is allowed.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End If 'Disallows anything below $10 for paint price Dim decPaintPrice As Decimal decPaintPrice = CDec(txtPaintPrice.Text) If decPaintPrice < 10 Then MessageBox.Show("Minimum price for paint is $10.00.", "Price Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End If 'Prevents anything below one for number of rooms. Dim intRooms As Decimal intRooms = CInt(txtRooms.Text) GetTotalArea() ' This is my crappy way of fixing my error prevention from leaving $0 If sngTotalArea_ = 0 Then Exit Sub End If 'Calculates the amount of paint needed to perform the job. lblPaintGallons.Text = FormatNumber(sngTotalArea_ / sngSQF, 0) Dim decPaintGallons As Decimal decPaintGallons = CDec(lblPaintGallons.Text) Dim decTotalPaintCost As Decimal 'Calculates the total cost of paint. decTotalPaintCost = CDec(decPaintGallons * decPaintPrice) lblTotalPaintCost.Text = FormatCurrency(decTotalPaintCost) LaborHours() 'Calculates the total cost of labor. Dim sngLaborHours As Single sngLaborHours = CSng(lblLaborHours.Text) Dim decTotalLaborCost As Decimal decTotalLaborCost = CDec(sngLaborHours * sngSalary) lblTotalLaborCost.Text = FormatCurrency(decTotalLaborCost) 'Calculates the total cost. Dim decTotal As Decimal decTotal = CDec(decTotalLaborCost + decTotalPaintCost) lblTotal.Text = FormatCurrency(decTotal) End Sub Function GetTotalArea() As Single 'This function is to add the area of each room. sngTotalArea_ = 0 Dim decArea As Decimal 'To hold the area. Dim intRooms As Integer = 1 'Number of rooms needed to be painted Dim intCount As Integer = 1 'Loop Count Dim intInput As String 'To get the area input intRooms = CInt(txtRooms.Text) If intRooms < 1 Then MessageBox.Show("Enter positive numbers for number of rooms. Thank you.", "Error Room", MessageBoxButtons.OK, MessageBoxIcon.Error) Return sngTotalArea_ Exit Function End If ' Following loop gets the area of each room. Do While intCount <= intRooms intInput = InputBox("Enter the area of room " & intCount.ToString, "Input Needed") If IsNumeric(intInput) = False Then intInput = InputBox("Enter the area of room" & intCount.ToString, "Input Needed", "Please enter a positive integer.") Return sngTotalArea_ End If If intInput < 0 Then End If If intInput <> "" Then decArea = CInt(intInput) sngTotalArea_ += decArea intCount += 1 End If Loop Return sngTotalArea_ End Function Function LaborHours() As String Dim sngPaintGallons As Single sngPaintGallons = CInt(lblPaintGallons.Text) lblLaborHours.Text = FormatNumber(sngPaintGallons * intHours, 0) Return lblLaborHours.Text 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() 'Prevents a running total sngTotalArea_ = 0 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 lblTotalPaintCost.Text = String.Empty lblTotalLaborCost.Text = String.Empty lblTotal.Text = String.Empty End Sub End Class