计数分析编号步骤-1至0(1 / 2、2 / 3和3/3)

时间:2019-04-18 09:04:54

标签: vb.net

如何使此代码起作用?假设我们在Textbox1中具有以下内容:(2,4,6)-将被扫描以确定分析的文本框。

TxtBoxIntDraws.Lines(0) = 3,6,7,9
TxtBoxIntDraws.Lines(1) = 2,6,9,10
TxtBoxIntDraws.Lines(2) = 3,5,7,10

然后它将得到:>

,如果存在,则计数重置为0,如果不存在,则计数重置为1。分析将从最后一行开始到第一行。 TxtBoxIntDraws.Lines(2)-并以TxtBoxIntDraws.Lines(0)

完成
1/3 - 0 (because one value exists 2 or 4 or 6, in TxtBoxIntDraws.Lines(0), 
2/3 - 1 (because not not 2/3 - 2,6 or 4,6) and +1 add to value. 
3/3 - 3 (because not 3/3 - 2,4,6) and +1 add to value. 

因此,简要地分析一下1 / 3、2 / 3和3/3,如果该值存在,则它将为0,如果该值不存在,则将其加+1。它必须从第-1步的步骤-1。我正在尝试编写此代码,但我没有做任何工作。

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim lastDraw1 As Integer = 0    '1/3
        Dim lastDraw2 As Integer = 0    '2/3
        Dim lastDraw3 As Integer = 0    '3/3
        For i As Integer = Step to -1 To TxtBoxIntDraws.Lines.Count - 0
            Dim lineVals As String() = TxtBoxIntDraws.Lines(i).Split(",")
            Select Case lineVals.Count()
                Case 1
                    lastDraw1 = 0
                    lastDraw2 += 1
                    lastDraw3 += 1
                    TextBox1.Text = lastDraw1
                    TextBox2.Text = lastDraw2
                    TextBox3.Text = lastDraw3
                Case 2
                    lastDraw1 = 0
                    lastDraw2 = 0
                    lastDraw3 += 1
                    TextBox1.Text = lastDraw1
                    TextBox2.Text = lastDraw2
                    TextBox3.Text = lastDraw3
                Case 3
                    lastDraw1 = 0
                    lastDraw2 = 0
                    lastDraw3 = 0
                    TextBox1.Text = lastDraw1
                    TextBox2.Text = lastDraw2
                    TextBox3.Text = lastDraw3
                Case Else
                    'This should probably also be handled
            End Select
        Next
    End Sub

1 个答案:

答案 0 :(得分:0)

不确定您要做什么,而是要修复For ... Next

    Dim StartIndex = TxtBoxIntDraws.Lines.Length - 1
    For i = StartIndex To 0 Step -1
        'Your code here
    Next