【发布时间】:2018-09-30 21:26:37
【问题描述】:
with-block 变量是否有关键字?例如,如果该关键字是 This,则以下代码将起作用:
With New myType
.DoSomething
DoSomethingElse "abc", This, 123
End With
【问题讨论】:
标签: vba with-statement
with-block 变量是否有关键字?例如,如果该关键字是 This,则以下代码将起作用:
With New myType
.DoSomething
DoSomethingElse "abc", This, 123
End With
【问题讨论】:
标签: vba with-statement
恐怕这样的关键字不存在。在 Visual Basic 中,我为此编写了一个扩展方法 .Myself。在 VBA 中我不知道任何解决方案。当然你可以使用局部变量。
Set a = New mytype
a.DoSomething
DoSomethingElse "abc", a, 123
【讨论】:
您可以将以下 Function 添加到您的 MyType 类中
Public Function This() As MyType
Set This = Me
End Function
以便您的主要代码可以如下利用它:
With New MyType
.DoSomething
DoSomethingElse "abc", .This, 123
End With
【讨论】: