整数不能转换为Integer()类型?

时间:2017-08-07 08:12:17

标签: arrays vb.net type-conversion

我的代码是通过在程序的另一部分中调用子例程来数字化整数记录数组,但由于某种原因,它不接受不让它编译的输入。

我有一个名为materials()的数组,它包含ID和名称之类的东西但是当我调用子程序quicksort(list(),first,last)时,它会给出一个错误,即Integer类型无法转换为Integer类型( )。

这两种类型有区别吗?以及我如何解决这个问题以便对ID进行排序?

CODE:

prgFunctions.quickSortInt(materials(numMatFile).matID, 1, numMatFile)

调用:

Public Shared Sub quickSortInt(ByRef list() As Integer, ByVal first As Integer, ByVal last As Integer)

        'FIX THIS list() needs to match somehow with the array being called

        'Low is the beginning index, high is the final index initially. Midvalue is between both.
        Dim high, low, midValue As Integer
        low = first
        high = last
        midValue = list((first + last) \ 2)

        'Function sorts by comparing the value at low to the mid value, and if it is less than it 
        'ignores and steps up the index.
        Do
            While list(low) < midValue
                low = low + 1
            End While

            'Repeat for the high value but step down the index.
            While list(high) > midValue
                high = high - 1
            End While

            'When both while loops have finished (ie. low value is equal to or higher than the 
            'mid and vice versa for high) it checks whether the low index is less than or equal 
            'to the high index, then swaps the values.
            If low <= high Then
                swapInt(list(low), list(high))
                low = low + 1
                high = high - 1
            End If

            'Loop while the low index is less than or equal to the high index
        Loop While low <= high

        'When the first index is less than the high index, use recursion to sort new sublists
        If first < high Then
            quickSortInt(list, first, high)
        End If

        'Same for low and last
        If low < last Then
            quickSortInt(list, low, last)
        End If
    End Sub

对于一堆乱七八糟的代码感到抱歉,我从一个非常古老的2003论坛帖子中复制了大部分代码并修复它以使其正常工作,但它在这个实例中不起作用。我也是编码的新手。谢谢你的帮助!

0 个答案:

没有答案