我的vb比较差,我把我的问题简化一下吧。有三个数组a(),b(),c(),每个数组中存放着10个数,这些数都是随机的,而且a(),b(),c()同一下标时各个数是关联的。现在要按a()对这三个数组里的数进行升序排列:例如a(3)是最小的,那么把a(3),b(3),c(3)一起调换到第一组,依次类推
不知道各位大侠听明白没有?

解决方案 »

  1.   

    最简单的思路就是把数据放数据库中order by一下再查出放入数组既然各个数组的下标有关联
    你排a()数组,其他数组调用时用a数组的下标就行了啊
      

  2.   

    我也是新手,呵呵
        Dim a(3) As Integer
        Dim b(3) As String
        Dim c(3) As String
        Dim i As Integer
        Dim j As Integer
        Dim t As Integer
        a(0) = 5
        a(1) = 2
        a(2) = 65
        b(0) = "a"
        b(1) = "sd"
        b(2) = "fd"
        c(0) = 4
        c(1) = 5
        c(2) = 5
        For i = 0 To UBound(a) - 1
            For j = i To UBound(a) - 1
                If a(i) < a(j) Then
                    t = a(i)
                    a(i) = a(j)
                    a(j) = t
                    t = b(i)
                    b(i) = b(j)
                    b(j) = b(i)
                    t = c(i)
                    c(i) = c(j)
                    c(j) = c(i)
                End If
            Next j
        Next i
      

  3.   

    错了,应将t声明为Variant类型
      

  4.   

    我说 的关联的意思是指他们必须一起变动,不能分开。chenanlin1981(小黑) 的想法是对的,我当时也是这么想的,可是实现不了,中间好像存在问题,而且你用的好像是降序排列
      

  5.   

    Dim a(9) As Integer
        Dim b(9) As Integer
        Dim c(9) As Integer
        Dim i As Integer
        Dim j As Integer
        Dim t As Integer
        
        For i = 0 To 9
            a(i) = Int(Rnd * 20)
            b(i) = Int(Rnd * 20)
            c(i) = Int(Rnd * 20)
            Debug.Print a(i); b(i); c(i)
        Next    Debug.Print ""
        
        For i = 0 To 8
            For j = i To 9
                If a(i) > a(j) Then
                    t = a(i)
                    a(i) = a(j)
                    a(j) = t
                    t = b(i)
                    b(i) = b(j)
                    b(j) = t
                    t = c(i)
                    c(i) = c(j)
                    c(j) = t
                End If
            Next
        Next
        
        For i = 1 To 9
            Debug.Print a(i); b(i); c(i)
        Next
      

  6.   

    http://community.csdn.net/Expert/topic/4715/4715867.xml?temp=.698086