在VB.NET标签中的下一行打印

时间:2013-09-07 12:09:13

标签: vb.net label

这是我的代码:

Private Sub btn_Validate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Validate.Click
    Call ValidateData(txt_score1.Text, "1")
    Call ValidateData(txt_score2.Text, "2")
    Call ValidateData(txt_score3.Text, "3")
    Call ValidateData(txt_score4.Text, "4")
End Sub

Private Sub ValidateData(ByVal vScore As String, ByVal vintScore As String)
    If (vScore = "") Then
        lbl_StatusContent.Text = vbCrLf & "Score " & vintScore & " is blank"
    ElseIf Not (IsNumeric(vScore)) Then
        lbl_StatusContent.Text = vbCrLf & "Score " & vintScore & " is not numeric"
    ElseIf (vScore < 0 And vScore > 10) Then
        lbl_StatusContent.Text = vbCrLf & "Score " & vintScore & " is not in range: 0-10"
    Else
        lbl_StatusContent.Text = vbCrLf & "Score " & vintScore & " is Valid"

    End If
    vintScore = vintScore + 1
End Sub

问题是它只显示我的得分4结果。得分1,得分2和得分3正在与第四个重叠。

我想要下一行中的所有内容。所以我可以看到所有4个分数,没有人重叠。

2 个答案:

答案 0 :(得分:0)

  

我想在下一行中找到所有这些内容。

我认为您正在寻找vbnewlineEnvironment.NewLine

答案 1 :(得分:0)

当然,你只能看到最后的结果。每次调用该方法时,都会覆盖以前的输出。我认为你需要一些东西来连接结果并一起打印

Private Sub btn_Validate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Validate.Click
    Dim result As String 
    result = ValidateData(txt_score1.Text, "1")
    result = result & ValidateData(txt_score2.Text, "2")
    result = result & ValidateData(txt_score3.Text, "3")
    result = result & ValidateData(txt_score4.Text, "4")
    lbl_StatusContent.Text = result
End Sub

Private Function ValidateData(ByVal vScore As String, ByVal vintScore As String) As String
    Dim result As String
    If (vScore = "") Then
        result = vbCrLf & "Score " & vintScore & " is blank"
    ElseIf Not (IsNumeric(vScore)) Then
        result = vbCrLf & "Score " & vintScore & " is not numeric"
    ElseIf (vScore < 0 And vScore > 10) Then
        result = vbCrLf & "Score " & vintScore & " is not in range: 0-10"
    Else
        result = vbCrLf & "Score " & vintScore & " is Valid"
    End If
    return result
End Function

并确保lbl_StatusContext.Height足以容纳至少4行文本