编译错误:byRef参数类型不匹配

时间:2013-05-24 05:09:06

标签: vb.net

我正在编译时发生错误。一个byref参数类型不匹配提示。 “setStandard s2.day(dCnt)”部分突出显示。不知道如何解决它。 dCnt,wCnt,tCnt和wCnt都声明为整数。

Private Sub S2_Sort()
    Dim x As Integer, t As Integer
    x = 0
    t = tCnt
    'loop record
    Do While x < t
        'loop day
        For dCnt = 1 To UBound(S2.Day())

            'inpDate = S2.Day(dCnt).DayVal
            ReDim S2.Day(dCnt).tList(0)

            'If DateValue(S2.Day(dCnt).DayVal) = DateValue(DataRecord(x).StartTime) Then

            'loop shift
                For tCnt = 1 To UBound(TaskID())

                    ReDim Preserve S2.Day(dCnt).tList(tCnt)
                    ReDim Preserve S2.Day(dCnt).tList(tCnt).sList(0)

                    dicShift.RemoveAll
                    'If x <= UBound(DataRecord()) Then
                        'If GetTimestamp(S2.Day(dCnt).DayVal, Shift(sCnt).StartHour, Shift(sCnt).HourLen, Shift(sCnt).NextDay, DataRecord(x)) Then
                            'loop task
                            For sCnt = 1 To UBound(Shift())

                                ReDim Preserve S2.Day(dCnt).tList(tCnt).sList(sCnt)
                                ReDim Preserve S2.Day(dCnt).tList(tCnt).sList(sCnt).TaskRecList(0)

                                wCnt = 0
                                'Do While x <= UBound(DataRecord())
                                    ReDim Preserve S2.Day(dCnt).tList(tCnt).sList(sCnt).TaskRecList(wCnt)
                                    ''state here all the conditions
                                    If x <= UBound(DataRecord()) Then
                                        If GetTimestamp(S2.Day(dCnt).DayVal, Shift(sCnt).StartHour, Shift(sCnt).HourLen, Shift(sCnt).NextDay, DataRecord(x)) Then
                                            If DataRecord(x).TaskID = TaskID(tCnt).TaskID Then
                                                'should contain the tasks
                                                dicDay.RemoveAll

                                                'get the work time number and list it on stLIst
                                                'S2.Day(dCnt).sList(sCnt).ShiftName = ""
                                                'S2.Day(dCnt).sList(sCnt).tList(tCnt).ResourceName = ""
                                                S2.Day(dCnt).tList(tCnt).sList(sCnt).TaskRecList(wCnt) = x

                                                'Compute for task, for the shift, for the day
                                                'compute pataas
                                                S2.Day(dCnt).tList(tCnt).sList(sCnt).Val = S2_Compute(x, S2.Day(dCnt).tList(tCnt).sList(sCnt).Val)
                                                S2.Day(dCnt).tList(tCnt).Val = S2_Compute(x, S2.Day(dCnt).tList(tCnt).Val)
                                                S2.Day(dCnt).tList(tCnt).MstUnit = DataRecord(x).MeasurementUnit
                                                S2.Day(dCnt).tList(tCnt).Cost = DataRecord(x).Cost
                                                S2.Day(dCnt).tList(tCnt).ResourceName = S2.Day(dCnt).tList(tCnt).ResourceName + DataRecord(x).ResourceName
                                                S2.Day(dCnt).Val = S2_Compute(x, S2.Day(dCnt).Val)

                                                x = x + 1
                                                wCnt = wCnt + 1
                                            End If
                                        End If
                                    End If
                                'Loop 'task record
                            Next sCnt 'Next Shift
                        'End If 'shift
                    'End If 'x <datarecord
                Next tCnt 'Next Task
            'End If 'day
            setStandard S2.Day(dCnt).Val
        Next dCnt 'Next Day
    Loop
End Sub

1 个答案:

答案 0 :(得分:0)

我在回答之前尝试重新制定问题。起初我考虑过编辑,但我不确定我是否正确理解了qustion。我想这是关于 vb6 而不是vb.net,因为setStandard S ...必须在vb.net中setStandard (S ...)并且被Visual Studio自动替换。

<强>问题: 为什么我在编译行时获得byRef Argument type mismatch

setStandard S2.Day(dCnt).Val

功能签名是:

Private Function setStandard(Rec As Double) '

其他有点不同版本的代码位于by ref argument type mismatch VB 6.0

答案: S2.Day(dCnt).Val可能不是Double所以你可以试试

setStandard CDbl(S2.Day(dCnt).Val) 

Private Function setStandard(ByVal Rec As Double) '

另请检查.Val函数声明以查找其数据类型。随意编辑我的答案或使用我的文本进行问题重新制定。