-3

编译时出现错误。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
4

1 回答 1

0

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

问题: 为什么我byRef Argument type mismatch在编译行时得到

setStandard S2.Day(dCnt).Val

函数签名是:

Private Function setStandard(Rec As Double) '

其他有点不同的代码版本在ref 参数类型不匹配 VB 6.0中。

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

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

或者

Private Function setStandard(ByVal Rec As Double) '

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

于 2013-05-25T22:12:31.677 回答