更改一个TextBox值将另一个值归零

时间:2015-07-24 13:35:27

标签: asp.net vb.net textbox global-variables

我再次。我不知道为什么我可以用Windows表单飞行,但没有文字或网站让我理解网页表格......叹息。所以这是现在的程序片段:

<script runat="server">

Protected principle As Single = 0.0
Protected months As Single = 0.0
Protected rate As Single = 0.0

Protected Sub PrincipleTextBox_TextChanged(sender As Object, e As EventArgs)
    If IsPostBack Then
        Validate()
        If IsValid Then
            principle = Single.Parse(PrincipleTextBox.Text)
            PrincipleTextBox.Text = FormatCurrency(principle)
        End If
    End If
End Sub

Protected Sub TimeTextBox_TextChanged(sender As Object, e As EventArgs)
    If IsPostBack Then
        Validate()
        If IsValid Then
            months = Single.Parse(TimeTextBox.Text)
            TimeTextBox.Text = FormatNumber(months, 0, TriState.UseDefault, TriState.False, TriState.True)
        End If
    End If
End Sub

它继续。现在,在PrincipleTextBox中输入一个有效数字,原则似乎设置为该值,非常棒。在TimeTextBox中输入一个值,原则恢复为0.0。为什么?如何设置变量然后取消设置?

再次感谢任何建议或指导。我知道我还需要添加其他东西(TryParse,一个),但我只需要在继续之前解决这个问题。

0 个答案:

没有答案