守则有两个选择。选项一以1美元开始,每天加倍,持续10天。如果这是正确的,那么该值应该是1024美元,而是显示加倍($ 2046)
第二个选项以100美元开始,每天增加100美元,为期10天。这个数字应该达到1000美元,而不是显示6500美元
Public Class Form1
Private Sub compareButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles compareButton.Click
Dim initValue1 As Integer = 1
Dim value1 As Integer
Dim initValue2 As Integer = 100
Dim value2 As Integer
Integer.TryParse(Option1TextBox.Text, value1)
Integer.TryParse(Option2TextBox.Text, value2)
For day As Integer = 1 To 10
initValue1 = initValue1 * 2
value1 += initValue1
Next day
Option1TextBox.Text = value1.ToString("C2")
For day As Integer = 1 To 10
initValue2 = initValue2 + 100
value2 += initValue2
Next day
Option2TextBox.Text = value2.ToString("C2")
End Sub
End Class
我觉得我犯的是一个很小的错误。有什么帮助吗?
答案 0 :(得分:2)
试试这个:
不需要 value1 + = initValue1 和 value2 + = initValue2 删除它们并尝试
Dim initValue1 As Integer = 1
Dim value1 As Integer
Dim initValue2 As Integer = 100
Dim value2 As Integer
Integer.TryParse(Option1TextBox.Text, value1)
Integer.TryParse(Option2TextBox.Text, value2)
For day As Integer = 1 To 9
initValue1 = initValue1 * 2
Next
Option1TextBox.Text = initValue1.ToString("C2")
For day As Integer = 1 To 9
initValue2 = initValue2 + 100
Next
Option2TextBox.Text = initValue2.ToString("C2")