更新标签文字

时间:2019-01-13 18:47:52

标签: vb.net

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If rdorooms.Checked = True And chkgroup.Checked = True Then
        price = 32.5
        lblmessage.Text = lblmessage.Text & price
    ElseIf rdorooms.Checked = True Then
        price = nudpeople.Value * 10
        lblmessage.Text = lblmessage.Text & price
    End If
End Sub

单击Button1后,lblmessage会显示我需要的内容,但是再次单击时,它会显示以前的结果添加到当前结果中。

例如, lblmessage = 32.5 然后再次点击 lblmessage = 32.532.5 等等

我不希望那样发生。

1 个答案:

答案 0 :(得分:2)

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If rdorooms.Checked = True And chkgroup.Checked = True Then
        price = 32.5

    ElseIf rdorooms.Checked = True Then
        price = nudpeople.Value * 10

    End If
    lblmessage.Text = price

End Sub