0

私は、投資額を受け取り、毎年合計の 5% のリターンを生み出し、年ごとの結果を に表示する投資リターン アプリケーションを持っていますListBox。エラーは発生していませんが、GUI のリストボックスに投資利回りが表示されません。任意の提案をいただければ幸いです。これは私がこれまでに持っているコードです:

 Public Class Form1

        Const Interest_Rate As Double = 0.05

Private Sub btncmdCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncmdCalculate.Click

   Dim num_years As Integer
   Dim intCounter As Integer
   Dim current_value As Double
   Dim future_amount As Double

   current_value = Val(txtcurrent_value.Text)
       num_years = Val(txtnum_years.Text)
   current_value = current_value * Interest_Rate * num_years & vbTab _
            'calculate amount

   For intCounter = 1 To num_years
        future_amount = current_value * (1 + Interest_Rate) ^ intCounter

        lstBalances.Text = current_value * Math.Pow(1 + Interest_Rate, intCounter) &    "" & _ vbTab & FormatCurrency(current_value)"

   Next intCounter
End Sub
4

2 に答える 2

2

lstBalances がリストボックスの場合、Calcs を Items コレクションに追加する必要があります

lstBalances.Items.Add(current_value * Math.Pow(1 + Interest_Rate, intCounter) &  vbTab & _
                      FormatCurrency(current_value))

余談ですが、私はあなたの計算式を本当に理解していないので、あなたがしていることが正しいかどうかはわかりません。リストボックスでプログラミングの問題を解決しようとしているだけです.....

于 2013-04-11T16:04:04.473 に答える
0

ループの繰り返しごとにリストボックスのテキストを設定しているようです。あなたの説明から、反復ごとに値を追加したいように思えます。たとえば、次のようになります。

lstBalances.Text &= current_value * Math.Pow(1 + Interest_Rate, intCounter) & vbTab & FormatCurrency(current_value) & vbCrLf
于 2013-04-11T16:01:05.880 に答える