Public Class Form1 Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged End Sub Private Sub HoursTxtBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HoursTxtBox.TextChanged End Sub Private Sub CalculateBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateBtn.Click 'Error Trapping and Data Checking Step 1 Dim ok As String ok = "yes" 'Data conversion Step 1 For each textbox and label involved you needed to create ' a str and a number object Dim strHours As String Dim strSales As String Dim decHours As Decimal Dim decSales As Decimal Dim decBonus As Decimal Dim strBonus As String 'DC Step 2 Convert input text to string strSales = Me.TextBox1.Text strHours = Me.HoursTxtBox.Text 'DC Step 3 Convert string to decimal 'Remember when you convert from string to decimal, blowups can happen so 'We catch the errors in this step 'Error trapping and data checking Step2 'Method A - Try Catch Try decHours = CDec(strHours) Catch MessageBox.Show("Hours must be a number", "Error") ok = "no" End Try Try decSales = CDec(strSales) Catch MessageBox.Show("Sales must be a number", "Error") ok = "no" End Try 'Method B - End IF testubg on data values If decHours > 160 Then MessageBox.Show("Who are you trying to kid, no more than 160 allowed in hours worked", "Error") ok = "no" End If 'Error trapping and data checking Step 3 If ok = "no" Then Bonus.Text = "Bad Data please fix" Else 'DC Step 4 Calculate, Sometimes you need to break your calculation 'to preserve precision also try to keep data types the same to avoid rounding decBonus = decHours / 160 decBonus = decBonus * 0.02 decBonus = decBonus * decSales 'DC Step 5Convert our result decimal to string strBonus = CStr(decBonus) 'DC Step 6 Convert string to text Me.Bonus.Text = "$" & strBonus End If End Sub Private Sub ClearBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearBtn.Click Me.NameTxtBox.Clear() Me.HoursTxtBox.Clear() End Sub Private Sub ExitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitBtn.Click Me.Close() End Sub End Class Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Conversion Path step 1 'Create string and numeric object pairs, one pair for each text property you are using 'on the form Dim str1 As String Dim dec1 As Decimal Dim strResults As String Dim decResults As String 'Conversion Path step 2 'Convert from text to string str1 = TextBox1.Text 'Conversion Path step 3 'Convert from string to numeric (decimal in this case) dec1 = CDec(str1) 'Conversion Path step 4 'Multiply by 2 decResults = dec1 * 2 'Conversion Path step 5 'convert decimal to string strResults = CStr(decResults) 'Conversion Path step 6 'Convert string to text property on form Label2.Text = strResults End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click End Sub End Class Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Declare or dimension variables needed for calculations Dim decRemMiles As Decimal Dim decDolsPerMile As Decimal Dim decCentsPerMile As Decimal 'Step 1 conversion path set up string numeric pairs Dim strexp As String Dim strcurr As String Dim strpricepaid As String Dim strresults As String Dim Dim Dim Dim decexp As Decimal deccurr As Decimal decpricepaid As Decimal decresults As Decimal 'Step 2 Convert from text to string strexp = txtexp.Text strcurr = txtcurr.Text strpricepaid = txtpricepaid.Text 'Step 3 Convert from string to numeric Try decexp = CDec(strexp) deccurr = CDec(strcurr) decpricepaid = CDec(strpricepaid) Catch MsgBox("Hey bad data") Me.Close() End Try 'Step 4 Do our mathematics, our calculations decRemMiles = decexp - deccurr decDolsPerMile = decpricepaid / decRemMiles decCentsPerMile = decDolsPerMile * 100 decresults = decCentsPerMile 'Step 5 convert from decimal to string strresults = CStr(decresults) 'Step 6 convert from string to text (puts on the form) lblresults.Text = strresults End Sub End Class