parameters - 局部变量优先于属性?
问题描述
我正在研究一些 VB6,它在类定义中有一些代码,归结为:-
Private intMyValue as Integer
Public Property Get MyValue as Integer
MyValue = intMyValue
End Property
Public Sub DoFoo (ByVal MyValue As Integer)
Dim bar As Integer
bar = MyValue
End Sub
问题是:在对 的赋值中bar
,使用的是属性还是参数?
解决方案
一种检查方法是查看 IDE 认为将使用什么。
这是一个例子:
Property Get test() As Integer
test = 1
End Property
Private Sub test2(test As Integer)
Debug.Print test 'Place cursor here
End Sub
如果将光标放在test
指示的行上并按Shift+ f2(或右键单击并选择定义),它会突出显示test
in test As Integer
(参数)。
作为仔细检查,如果您将参数重命名为其他名称并再次执行此操作,则它会突出显示名为test
.
我认为这与编译器一致。
推荐阅读
- python - 带有过滤器的滚动平均值 - Python
- c - .exe 在 C 中无法正确关闭
- javascript - 偶尔 (404) 未找到,用于 SpreadsheetsService.Query
- go - Go API 在 GCP 网络连接中心创建 hub/spoke
- python - 比较两个 python 列表时访问最小值
- outlook-addin - 在 Outlook 项目发送事件处理程序中,单击消息发送时抛出的发送按钮错误
- mysql - SQLAlchemy mysql 无法获取正确的字符集
- python - 在 django 中访问 sqlite3 中的异常线程
- python - OpenCV线检测python
- javascript - Javascript - 按多个值对对象进行排序