更新时间:2023-11-29 23:38:28
尝试一下(更新以显示ASPX和VB代码,并带有几个静态值进行测试)
Try this (UPDATED TO SHOW ASPX and VB code with a couple of static values for test)
aspx代码
<asp:TextBox ID="txtsurcharges" runat="server" Text="£5" AutoPostBack="true"></asp:TextBox>
<asp:TextBox ID="txttotal" runat="server" Text="£5"></asp:TextBox>
vb代码
Private Sub txtsurcharges_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsurcharges.TextChanged
Dim c As Integer
c = CInt(txtsurcharges.Text) + CInt(txttotal.Text)
txttotal.Text = c
End Sub
您可以
如果我现在将txtsurcharges更改为10,则txttotal将更改为15。
If I now change txtsurcharges to 10 then txttotal will change to 15.
当然,您需要确保只能在txtsurcharges中键入数字。
You will of course need to make sure that only numerics can be typed into txtsurcharges.