当前位置: 代码迷 >> VB Dotnet >> 疑难嵌套循环
  详细解决方案

疑难嵌套循环

热度:106   发布时间:2016-04-25 02:09:37.0
疑难嵌套循环求助
各位前辈大德:

后生有个循环的问题想求助大家,希望前辈给予指点迷津: 

现在有一个数组,64个,每一个里面是"0101010101"这样的数据,然后分为4行一组,就是16组

我写了个循环,必须是先按照组才能对应到行,0-63行,例如

For i = 0 to 15
        msgbox("第" &  i & "组数据组号:" & i)

    For j = 0 to 63
            Msgbox("第" &  i & "组数据组内容:" & j)
    Next

Next

必须是每一组组对应才可以显示组里面的行,请各位前辈指点指点.

------解决思路----------------------
dim a(63)

For i = 0 to a.length /4 -1
        msgbox("第" &  i & "组数据组号:" & i)

    For j = 0 to 3
            Msgbox("第" &  i & "组数据组内容:" & a(i*4+j))
    Next

Next
------解决思路----------------------
二进制数按自己需要修改或更新吧。


Public Class Class1


    Private Dictionary1 As New Dictionary(Of Integer, String())
    Sub New()


        Dictionary1.Add(0, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(1, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(2, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(3, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(4, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(5, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(6, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(7, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(8, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(9, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(10, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(11, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(12, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(13, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(14, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})
        Dictionary1.Add(15, New String() {"0101010101", "0101010101", "0101010101", "0101010101"})

    End Sub



    Sub MySub()

        Dim Count1 As Integer = Dictionary1.Count - 1
        Dim Array1 As String()
        Const Info1 As String = "组数据组号"
        Const Info2 As String = "内容信息"
        Dim View1 As String
        For index1 As Integer = 0 To Count1
            Array1 = Dictionary1.Item(index1)
            For index2 As Integer = 0 To UBound(Array1)
                View1 = Array1(index2)
                MsgBox(index1 & Info1 & index2 & Space(1) & Info2 & Space(1) & View1)
            Next

        Next
    End Sub

'如下是窗体代码
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim Cls1 As New Class1
        Cls1.MySub()
    End Sub
End Class

End Class
  相关解决方案