注册 登录
编程论坛 VB6论坛

定义了 MoveType 枚举类型,为何但还是编译错误:用户定义类型未定义?

wlbwxd 发布于 2023-10-28 10:32, 1055 次点击
以下是模块代码,显示编译错误,请各位大神帮忙看看问题在哪?
' 移动记录类型的枚举
Public Enum moveType
    FirstRecord = 12
    PreviousRecord = 13
    NextRecord = 14
    LastRecord = 15
End Enum

' 函数名:MoveRecord
' 函数功能:控制表格记录前后移动
' 参数说明:moveType 移动记录类型(使用MoveType枚举)
'           vsf 表格控件
' 返回值:无
Public Sub MoveRecordA(moveType As moveType, ByVal vsf As VSFlexGrid)
    Dim H As Integer
    With vsf
        H = (.Height \ .CellHeight) - 2
        
        Select Case moveType
            Case moveType.FirstRecord
                If .Rows > .FixedRows Then
                    .Row = .FixedRows
                    .TopRow = .FixedRows
                End If
            Case moveType.PreviousRecord
                If .Row > .FixedRows Then
                    .Row = .Row - 1
                    If .Row - .TopRow < 0 Then
                        .TopRow = .TopRow - 1
                    End If
                End If
            Case moveType.NextRecord
                If .Row < .Rows - 1 Then
                    .Row = .Row + 1
                    If .Row - .TopRow > H - 1 Then
                        .TopRow = .TopRow + 1
                    End If
                End If
            Case moveType.LastRecord
                If .Rows > .FixedRows + 1 Then
                    .Row = .Rows - 1
                    If .Rows > H Then
                        .TopRow = .Rows - H
                    End If
                End If
        End Select
        
        ' 处理超出可见范围的情况
        If .Row - .TopRow < 0 Or .Row - .TopRow > H Then
            .TopRow = Abs(.Row - H)
        End If
    End With
End Sub
2 回复
#2
apull2023-10-28 12:14
参数类型和参数名同名了哈。

#3
wlbwxd2023-10-28 12:37
回复 2楼 apull,修改成这样才正常了
' 移动记录类型的枚举
Public Enum moveType
    FirstRecord = 12
    PreviousRecord = 13
    NextRecord = 14
    LastRecord = 15
End Enum

' 函数名:MoveRecord
' 函数功能:控制表格记录前后移动
' 参数说明:moveType 移动记录类型(使用MoveType枚举)
'           vsf 表格控件
' 返回值:无
Public Sub MoveRecord(ByVal mType As Integer, ByVal vsf As VSFlexGrid)
    Dim H As Integer
    With vsf
        H = (.Height \ .CellHeight) - 2
        
        Select Case mType
            Case moveType.FirstRecord
                If .Rows > .FixedRows Then
                    .Row = .FixedRows
                    .TopRow = .FixedRows
                End If
            Case moveType.PreviousRecord
                If .Row > .FixedRows Then
                    .Row = .Row - 1
                    If .Row - .TopRow < 0 Then
                        .TopRow = .TopRow - 1
                    End If
                End If
            Case moveType.NextRecord
                If .Row < .Rows - 1 Then
                    .Row = .Row + 1
                    If .Row - .TopRow > H - 1 Then
                        .TopRow = .TopRow + 1
                    End If
                End If
            Case moveType.LastRecord
                If .Rows > .FixedRows + 1 Then
                    .Row = .Rows - 1
                    If .Rows > H Then
                        .TopRow = .Rows - H
                    End If
                End If
        End Select
        
        ' 处理超出可见范围的情况
        If .Row - .TopRow < 0 Or .Row - .TopRow > H Then
            .TopRow = Abs(.Row - H)
        End If
    End With
End Sub
1