我正在尝试为我的程序创建摘要,并且不知道如何执行此操作。 这是我的程序代码。这将使用存款,支票或服务费计算银行存款余额。它还为写入退回支票提供10美元的费用。
Private Sub CalculateTextBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateTextBox.Click
'Calculate the transaction and display the new balance
Dim AmountDecimal As Decimal
If DepositRadioButton.Checked Or CheckRadioButton.Checked Or ChargeRadioButton.Checked Then
Try
AmountDecimal = Decimal.Parse(AmountTextBox.Text)
If DepositRadioButton.Checked = True Then
BalanceDecimal += AmountDecimal
ElseIf CheckRadioButton.Checked = True Or ChargeRadioButton.Checked = True Then
If (BalanceDecimal - AmountDecimal > 0) Then
BalanceDecimal -= AmountDecimal
Else
MessageBox.Show("Insufficient Funds. Service charge of $10. ")
BalanceDecimal = BalanceDecimal + 10
End If
End If
BalanceTextBox.Text = BalanceDecimal.ToString("C")
Catch AmountException As FormatException
MessageBox.Show("Please make sure that only numeric data has been entered.",
"Invalid Entry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With AmountTextBox
.Focus()
.SelectAll()
End With
Catch AnyException As Exception
MessageBox.Show("Error: " & AnyException.Message)
End Try
Else
MessageBox.Show("Please select deposit, check, or service charge", "Input needed")
End If
End Sub
我创建了一个“摘要”按钮,该按钮将显示存款总数,存款总金额,支票数量以及支票的金额。不包括因资金不足而退回的支票,但包括10美元的费用。我不知道如何写这个摘要,并希望任何可能的帮助!我从哪里开始?我怎样才能做到这一点?
答案 0 :(得分:0)
我只是猜测,但我的猜测是每次用户点击CalculateTextBox
时,都会添加一笔存款。如果是这样,你可以有一个跟踪存款数量的变量:
Private deposits as Integer = 0
Private Sub CalculateTextBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateTextBox.Click
'Calculate the transaction and display the new balance
Dim AmountDecimal As Decimal
If DepositRadioButton.Checked Or CheckRadioButton.Checked Or ChargeRadioButton.Checked Then
...
If DepositRadioButton.Checked = True Then
BalanceDecimal += AmountDecimal
deposits += 1 'Assuming this is when the user makes a deposit.
'Or place this line wherever a deposit is made.
ElseIf CheckRadioButton.Checked = True Or ChargeRadioButton.Checked = True Then
...
End If
...
End If
End Sub