需要帮助前进到Visual Basic中的下一条记录

时间:2014-03-22 12:53:24

标签: visual-studio-2012

好的,我试图做的是我有一个表格来检索结果。但是,当我检索结果时,如果文件中只有2组结果,我只能检索NEXT结果。因此,如果文件中有超过2组结果,我需要帮助才能检索下一组结果

For C = 0 To UBound(Scoring) Step 3
        txtSearch.Text = Scoring(C)
        txtName.Text = Scoring(C + 1)
        txtMarks.Text = Scoring(C + 2)
 Next

1 个答案:

答案 0 :(得分:0)

我认为这样的事情可能是:

Public intPosition as integer ' This variable has to be Public to keep the position

Dim bytStep as byte 
bytStep = 3

' Go forward
If intPosition <= UBound(Scoring) - (bytStep - 1)
    intPosition = intPosition + bytStep
    txtSearch.Text = Scoring(intPosition)
    txtName.Text = Scoring(intPosition + 1)
    txtMarks.Text = Scoring(intPosition + 2)
End if

'Go backwards
If intPosition >= 0
    intPosition = intPosition - bytStep
    txtSearch.Text = Scoring(intPosition)
    txtName.Text = Scoring(intPosition + 1)
    txtMarks.Text = Scoring(intPosition + 2)
End if