我的代码需要一些工作
Public Class Form1
Dim Bread, TotalPrice As Double
Private Sub txtBread_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBread.TextChanged
If txtBread.Text = "" Then
TotalPrice = TotalPrice - Bread
lblBread.Text = Bread.ToString
lblPrice.Text = TotalPrice.ToString
Else
Bread = Val(txtBread.Text) * 3.25
lblBread.Text = Bread.ToString
TotalPrice = TotalPrice + Bread
lblPrice.Text = TotalPrice.ToString
End If
End Sub
End Class
我的文本框仅适用于一位数字。所以我的错误是当我在文本框中输入两位数字时,它实际上会更新我的标签,但是当我按下退格键时它不再更新。