将文本框输出移动到不同的文本框中

时间:2015-02-04 22:50:43

标签: vb.net

我试图将文本输出到另一个文本框中,一旦第一个文本框中有5个条目。例;我得分为100,200,300,200,200。现在,当我尝试输入一个新的分数时,它应该将它放在下一个文本框中,但不要同意。

Dim Testint As Integer ' define an Integer for testing
    Dim sampleTextBox(3) As TextBox
    sampleTextBox(0) = txtPlayer1Scores
    sampleTextBox(1) = txtPlayer2Scores
    sampleTextBox(2) = txtPlayer3Scores
    sampleTextBox(3) = txtPlayer4Scores
    Dim sampleLabel(3) As Label
    sampleLabel(0) = lblPlayer1Average
    sampleLabel(1) = lblPlayer2Average
    sampleLabel(2) = lblPlayer3Average
    sampleLabel(3) = lblPlayer4Average

    scoreArray(textCount, gameNumber - 1) = CInt(txtScoreInput.Text) ' subtracting 1 from the score array
    sampleTextBox(textCount).Text &= " Score:" & scoreArray(textCount, gameNumber - 1) & vbCrLf
    'output statement
    gameNumber = gameNumber + 1 'increment the counter

    If gameNumber > MAX_SCORE_LENGTH Then

        sampleTextBox(textCount).Focus()
        sampleTextBox(textCount).Enabled = False
        For i As Integer = 0 To 4 'Add the array values up
            scoreTotal += scoreArray(textCount, i)
        Next
        playerAverage = scoreTotal / MAX_SCORE_LENGTH
        sampleLabel(labelCount).Text = playerAverage
        ' I need the textbox switch here
        textCount = textCount + 1 
        labelCount = labelCount + 1 ' and labels

ElseIf textCount > MAX_PLAYERS Then
        'calculate team average
        btnEnterScore.Enabled = False
    Else
        lblEnterScore.Text = "Enter Score for game #" & gameNumber ' 5 scores have not be inputted, 
        txtScoreInput.Text = "" 'ask for more
        txtScoreInput.Focus() 'refocus the input textbox
    End If

1 个答案:

答案 0 :(得分:0)

修正了...将最大长度设置为15会强制它在15位数之后移动,当小于15位数时它也会起作用

txtscore1.MaxLength = 15