Fill This Form To Receive Instant Help
Homework answers / question archive / Quantity Price (sales in $ per unit) Variable Expenses per unit Fixed Expenses 300 $300 $125 $34,000 300 $300 $125 $1,000 0 $200 $100 $40,000 500 $0 $20 $22,000 200 $150 $0 $20,000 500 $200 $175 $35,000 1
Quantity Price (sales in $ per unit) Variable Expenses per unit Fixed Expenses
300 $300 $125 $34,000
300 $300 $125 $1,000
0 $200 $100 $40,000
500 $0 $20 $22,000
200 $150 $0 $20,000
500 $200 $175 $35,000
1. Run the attached project. Use the first and second rows of test data in the above table to test the application. The second set of data results in a run time error.
2. Return to design mode and open the code window for the form 1 form. Set Option Strict On for the form. Several Syntax errors result from setting Option Strict to On. Open the task list to view the errors resulting from setting Option Strict to On.
3. Declare all necessary variables and perform the necessary data conversions in the code to perform the calculations properly without Syntax errors.
4. Correct the run-time error that results from the data in row 2 of the above table. Do not modify the range of the NumericUpDown controls to fix the error. Rather, use the proper data types in the code and perform the necessary data conversions to handle the numeric data properly.
5. Format all output to the Textbox controls to currency where currency values are used. Ratios are not currency values.
Code changed in Form1.vb in btnCalculate_Click
--------------------------------------------------------------------------------------------------------------
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim shrNetIncome As Integer
txtSalesTotal.Text = Format((nudQuantity.Value * nudSalesPerUnit.Value).ToString(),"Currency")
txtVarExpenses.Text = Format((nudQuantity.Value * nudVarExpensesPerUnit.Value).ToString(), "Currency")
txtCM.Text = Format((CDbl(txtSalesTotal.Text) - CDbl(txtVarExpenses.Text)).ToString(), "Currency")
txtCMPerUnit.Text = Format((nudSalesPerUnit.Value - nudVarExpensesPerUnit.Value).ToString(), "Currency")
shrNetIncome = Convert.ToInt32(CDbl(txtCM.Text) - nudFixedExpenses.Value)
txtNetIncome.Text = Format(Convert.ToString(shrNetIncome), "Currency")
txtCMRatio.Text = (CDbl(txtCM.Text) / CDbl(txtSalesTotal.Text)).ToString()
End Sub
please see the attached file