怎么做没有按钮的计数

时间:2018-02-03 07:07:57

标签: vb.net

我计划在没有Click Event的情况下进行计数,如果我从文本框中删除数字,我的“总数将回归零或无效”

这是我现在的代码我正在使用按钮:

Private Sub Hitung_Click(ByVal sender As System.Object, ByVal e As 
    System.EventArgs) Handles Hitung.Click
    txtTotal.Text = Val(txtgaji.Text) + Val(txtbonus.Text) + val(txttunjangan.Text) 
    End If
End Sub

1 个答案:

答案 0 :(得分:0)

Consider using TextBox1_KeyPress, TextBox1_KeyDown or TextBox1_KeyUp to trigger a re-evaluation of the contents of the TextBox (Which I have called TextBox1 in this instance) or your total. TextBox1_Change may also be relevant.

From what I understand of your question, if len(TextBox1.Text) = 0, you want to set your summing variable or total to 0 (txtTotal.Text ="0").