求教代码,急!
比如我在窗体里面有3个text控件,txtprice(单价),txtnumber(数量),txtsumprice(总额)
我在单价跟数量的控件里填上数值,想要自动在总额text控件里返回单价*数量的值
要怎么写代码!
求教,谢谢!
比较简单,刚好我会。
Private Sub txtprice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtprice.TextChanged
If IsNumeric(txtprice.Text) And IsNumeric(txtnumber.Text) Then
txtsumprice.Text = CStr(CDbl(txtprice.Text) * CDbl(txtnumber.Text))
End If
End Sub
Private Sub txtnumber_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnumber.TextChanged
If IsNumeric(txtprice.Text) And IsNumeric(txtnumber.Text) Then
txtsumprice.Text = CStr(CDbl(txtprice.Text) * CDbl(txtnumber.Text))
End If
End Sub
改了下,原来用了cint()转换,现在换成cdbl()
[此贴子已经被作者于2007-5-21 16:36:46编辑过]