gpt4 book ai didi

vba - 尝试在 Excel VBA 中将子语句拆分为多行

转载 作者:行者123 更新时间:2023-12-01 08:57:58 25 4
gpt4 key购买 nike

我正在尝试编写一个 sub 语句,该语句从另一个调用它的 sub 接收多个参数(抱歉,我对此很陌生 - 所以我的术语可能不正确)。

我传递的参数数量很多,所以它超出了我的屏幕。为方便阅读我想将参数列表拆分为多行 .我曾尝试像在 sub 中一样使用“空格下划线”技巧。 .但是,当我这样做时,VBA 停止识别 sub因为这是自己的日常。

任何想法我怎么能做到这一点?

例如。这有效:

... 
End Sub ' from previous subroutine

Sub openfile(ByVal Res, ByVal Book, ByVal inp) 'there are other arguments as well, but I have shortened them for convenience here.

....

End Sub

但这不会:
... 
End sub ' from previous subroutine

Sub openfile(ByVal Res, ByVal Book, _

ByVal inp) 'there are other arguments as well, but I have shortened them for convenience here.

....

End Sub

最佳答案

你不能有 完全 _之间的空行(空行)以及代码的下一部分。去掉多余的线,你会没事的。基本上,这样做:

Sub openfile(ByVal Res, ByVal Book, _
ByVal inp) 'there are other arguments as well, but I have shortened them for convenience here.

如果你真的想要一个几乎空白的行,你可以这样做:
Sub openfile(ByVal Res, ByVal Book, _
_
ByVal inp) 'there are other arguments as well, but I have shortened them for convenience here.

请注意 _那在它自己的行前面必须有一个空格字符;这很重要。

关于vba - 尝试在 Excel VBA 中将子语句拆分为多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25182790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com