Class 类属性在excel vba中不起作用

Class 类属性在excel vba中不起作用,class,excel,vba,Class,Excel,Vba,我试图自学如何使用vba类模块。这是我的类模块(名为clsWorkingRange)。以下是模块: Option Explicit Private pSheetName As String Private pColNum As Integer Public Property Get SheetName() As String SheetName = pSheetName End Property Public Property Let SheetName(SheetName As

我试图自学如何使用vba类模块。这是我的类模块(名为
clsWorkingRange
)。以下是模块:

Option Explicit

Private pSheetName As String
Private pColNum As Integer

Public Property Get SheetName() As String
    SheetName = pSheetName
End Property

Public Property Let SheetName(SheetName As String)
    pSheetName = SheetName
End Property

Public Property Get ColNum() As Integer
    ColNum = pColNum
End Property

Public Property Let ColNum(ColNumb As Integer)
    pColNum = ColNum
End Property

Public Function Get_Rows_Generic(work_sheet_get As String, column_num As Integer)
'worksheet is the name of a sheet in the form of a string
    Dim ws As Worksheet:             Set ws = Worksheets(work_sheet_get)
    Dim rows_count As Long:                 rows_count = ws.Cells(rows.Count, column_num).End(xlUp).Row
    Get_Rows_Generic = rows_count
End Function
我试图在这里起诉全班同学(在单独的模块中):


Debug.Print first\u class\u示例。ColNum
打印
0
。为什么属性不能作为1显示?

因为您应该更改它

Public Property Let ColNum(ColNumb As Integer)
    pColNum = ColNum
End Property
为此:

Public Property Let ColNum(ColNumb As Integer)
    pColNum = ColNumb
End Property
)

Public Property Let ColNum(ColNumb As Integer)
    pColNum = ColNumb
End Property