标签中有多条消息

时间:2015-03-22 08:06:46

标签: vb.net label vb.net-2010

我正在尝试创建它,所以我的标签显示每个文本框的输出,但它目前只显示最后一个块(txtboxCat)。

If (TxtboxS1.Text = "") Then
            LblStatusBox.Text = "Score 1 is blank"

        ElseIf IsNumeric(TxtboxS1.Text) = False Then
            LblStatusBox.Text = "Score 1 is not numeric"

        ElseIf (TxtboxS1.Text < 0 Or TxtboxS1.Text > 10) Then
            LblStatusBox.Text = "score 1 is not in the range 0-10"

        ElseIf (TxtboxS1.Text > 0 Or TxtboxS1.Text < 10) Then
            LblStatusBox.Text = "Score 1 is valid"

        End If


        If (TxtboxS2.Text = "") Then
            LblStatusBox.Text = "Score 2 is blank"

        ElseIf IsNumeric(TxtboxS2.Text) = False Then
            LblStatusBox.Text = "Score 2 is not numeric"

        ElseIf (TxtboxS2.Text < 0 Or TxtboxS2.Text > 10) Then
            LblStatusBox.Text = "score 2 is not in the range 0-10"

        ElseIf (TxtboxS2.Text > 0 Or TxtboxS2.Text < 10) Then
            LblStatusBox.Text = "Score 2 is valid"

        End If




        If (TxtboxS3.Text = "") Then
            LblStatusBox.Text = "Score 3 is blank"

        ElseIf IsNumeric(TxtboxS3.Text) = False Then
            LblStatusBox.Text = "Score 3 is not numeric"

        ElseIf (TxtboxS3.Text < 0 Or TxtboxS3.Text > 10) Then
            LblStatusBox.Text = "score 3 is not in the range 0-10"

        ElseIf (TxtboxS3.Text > 0 Or TxtboxS3.Text < 10) Then
            LblStatusBox.Text = "Score 3 is valid"


        End If



        If (TxtboxCat.Text = "") Then
            LblStatusBox.Text = "Category is blank"

        ElseIf Not TxtboxCat.Text = "A" Or TxtboxCat.Text = "B" Or TxtboxCat.Text = "C" Then
            LblStatusBox.Text = "catageory is not a valid value: A,B or C"

        ElseIf (TxtboxCat.Text = "A" Or TxtboxCat.Text = "B" Or TxtboxCat.Text = "C") Then
            LblStatusBox.Text = "Category is valid"



        End If

1 个答案:

答案 0 :(得分:1)

因为代码倾向于做你告诉它要做的事情。它勇敢地通过您的代码按顺序重新分配值,直到它结束。每次重新分配都会替换字符串。它不知道你想把它添加到最后,因为你没有告诉它。

找到一个字符串追加函数。创建一个空字符串。你说text = "stuff"的任何地方,用你找到的追加函数替换它,这样就有一个大字符串

最后,将该字符串放入您的标签中。