VBE 指向导致错误的这段代码:
Sheets("Topology").Range(Me.Get_Cell_Location).Interior.Color = RGB(255, 255, 255)
整个函数定义如下:
Public Function Colour_Me(choice As Integer) As Boolean
If choice = 1 Then
Debug.Print "Choice 1"
If Me.Get_Enabled1 = True Or Me.Get_Enabled2 = True Or Me.Get_Enabled3 = True Then
Sheets("Topology").Range(Me.Get_Cell_Location).Interior.Color = RGB(255, 255, 0)
Colour_Me = True
Else
Sheets("Topology").Range(Me.Get_Cell_Location).Interior.Color = RGB(255, 255, 255)
Colour_Me = False
End If
ElseIf choice = 2 Then
Debug.Print "Choice 2"
If Me.Get_Enabled1 = True Or Me.Get_Enabled2 = True Or Me.Get_Enabled3 = True Then
Sheets("Topology").Range(Me.Get_Cell_Location).Interior.Color = RGB(0, 0, 255)
Colour_Me = True
Else
Sheets("Topology").Range(Me.Get_Cell_Location).Interior.Color = RGB(255, 255, 255)
Colour_Me = False
End If
End If
End Function
选项 1 中的代码似乎可以正常工作,但选项 2 给我带来了问题。
更新
Public Property Let Set_Cell_Location(location As String)
cell_location = location
End Property
Public Property Get Get_Cell_Location()
Get_Cell_Location = cell_location
End Property