Code:
Option Explicit On
Option Strict On
Imports System.Globalization
Public Class MainForm
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' fills the combo box with values, then selects the first value
For years As Integer = 3 To 20
lifeComboBox.Items.Add(years.ToString)
Next years
lifeComboBox.SelectedIndex = 0
End Sub
[B]Private Sub displayButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles displayButton.Click
' displays a double-declining balance depreciation schedule
Dim cost As Double
Dim life As Double
Dim period As Double
Dim salvage As Double
Dim depreciation As Double
Dim isConvertedCost As Boolean
Dim isConvertedLife As Boolean
Dim isConvertedSalvage As Boolean
isConvertedCost = Double.TryParse(costTextBox.Text, _
NumberStyles.Currency, NumberFormatInfo.CurrentInfo, cost)
isConvertedLife = Double.TryParse(lifeComboBox.Text, life)
isConvertedSalvage = Double.TryParse(salvageTextBox.Text, _
NumberStyles.Currency, NumberFormatInfo.CurrentInfo, salvage)
If isConvertedCost AndAlso isConvertedLife AndAlso isConvertedSalvage Then
scheduleTextBox.Text = " Year Depreciation"
' write a For .... Next loop here to calculate the double declining balance
' depreciation and use a string concatenation to add the year and depreciation
' to the output text box.
Else
MessageBox.Show("The cost, life, and salvage values must be numeric.", _
"Sonheim Manufacturing Company", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End If[/B] costTextBox.Focus()
End Sub
Private Sub costTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles costTextBox.Enter
costTextBox.SelectAll()
End Sub
Private Sub costTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles costTextBox.TextChanged
scheduleTextBox.Clear()
End Sub
Private Sub lifeComboBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lifeComboBox.TextChanged
scheduleTextBox.Clear()
End Sub
Private Sub salvageTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles salvageTextBox.Enter
salvageTextBox.SelectAll()
End Sub
Private Sub salvageTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles salvageTextBox.TextChanged
scheduleTextBox.Clear()
End Sub
End Class
' depreciation and use a string concatenation to add the year and depreciation
' to the output text box.
Now I can write a for next statement but with string concatenation how would one do this
Comment