这是1个VB编程高人写的!我不会,请用delphi翻译下,并解释下面VB代码的意思!感谢中! 
Public Function ModeValue(ByVal Values As Variant) As Double
    Dim i As Long
    Dim LB As Long
    Dim UB As Long
    Dim mCount As Long
    Dim mMaxCount As Long
    
    Call SortValue(Values)    
    LB = LBound(Values)
    UB = UBound(Values)
    
    mCount = 1
    mMaxCount = 0
    ModeValue = Values(LB)
    For i = LB To UB - 1
        If Values(i) = Values(i + 1) Then
            mCount = mCount + 1
        Else
            If mCount > mMaxCount Then
                mMaxCount = mCount
                ModeValue = Values(i)
            End If
            mCount = 1
        End If
    Next
    If mCount > mMaxCount Then
        ModeValue = Values(UB)
    End If
End Function' 数组排序
Private Function SortValue(ByRef Values As Variant, Optional ByVal ForDirection As Boolean = True) As Long
    Dim i As Long
    Dim j As Long
    Dim LB As Long
    Dim UB As Long
    Dim mFlag as Long
    Dim mTemp As Variant    LB = LBound(Values)
    UB = UBound(Values)
    IF UB - LB <= 1 Then
        SortValue = 0
        Exit Function
    End IF    For i = LB To UB - 1
        For j = LB To LB + UB - i - 1
            mFlag = 0
            IF ForDirection Then
                IF Values(j) > Values(j + 1) Then mFlag = 1
            Else
                IF Values(j + 1) > Values(j) Then mFlag = 1
            End IF
            IF mFlag = 1 Then
                mTemp = Values(j)
                Values(j) = Values(j + 1)
                Values(j + 1) = mTemp
            End If
        Next
    Next
    SortValue = 1
End Function

解决方案 »

  1.   

    可以一句句翻译
    Dim i As Long
    变成
    i:long;
      

  2.   

    把您的意义翻译给我,小弟接触编程才半年,我自学的delphi呀!
      

  3.   

        Dim i As Long
        Dim LB As Long
        Dim UB As Long
        Dim mCount As Long
        Dim mMaxCount As Long
    var
      i,LB,UB,mcCount,mMaxCount:integer;

      i,LB,UB,mcCount,mMaxCount:longint;
     
      

  4.   

        第一段程序是调用排序SortValue并获取有序数组中重复数(计数)最多的元素(不返回排序结果,由ByVal定义传送值而不是地址),如果重复数最多的有并列情况,则返回第一个重复数元素。
        第二段程序是对数组进行【升序排序】并返回排序结果(数组,由ByRef定义传送地址)。如果给定无序数组元素小于2,则返回0,否则返回1。
        比如对于一个数值序列:
       4,2,8,5,3,0,1,7,9,6: 返回"4"
       4,2,8,5,8,0,1,7,9,6: 返回"8"
       4,2,8,9,8,0,1,7,9,6: 返回"8"
       9,2,8,9,8,0,1,7,9,6: 返回"9"