将文本框中的数字相乘并放入标签中

时间:2015-02-05 02:55:20

标签: c# textbox label

我有3个文本框,每个文本框都会转到相应的标签。它们是TB A至lbl A和TB B以标记B和TB C至lbl C和总lbl。 A乘以150,B乘以120,C乘以90.然后总标签以总标签显示。我正在使用C#

我有三个文本框(A,B,C)和三个相应的标签。当用户在文本框A中输入数字时,我希望将该数字乘以150放入标签A中; B乘以120,C乘以90.另外,我对所有乘法数字的总和有第四个标签。

我如何做到这一点?

2 个答案:

答案 0 :(得分:1)

没有看到任何代码,这是我能做的最好的事情:

int a = Convert.ToInt32(textboxA.Text) * 150;
int b = Convert.ToInt32(textboxB.Text) * 120;
int c = Convert.ToInt32(textboxC.Text) * 90;

lblA.Text = a.ToString();
lblB.Text = b.ToString();
lblA.Text = c.ToString();
lblTotal.Text = (a + b + c).ToString();

答案 1 :(得分:0)

Public Class Form1

Private Sub btnexit_Click(sender As Object, e As EventArgs) Handles btnexit.Click
    Me.Close()
End Sub
Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click
    TBAsold.Text = ""
    TBBsold.Text = ""
    TBCsold.Text = ""
End Sub
Private Sub btncal_Click(sender As Object, e As EventArgs) Handles btncal.Click

End Sub

结束班