gpt4 book ai didi

带有括号表达式的vba行继续

转载 作者:行者123 更新时间:2023-12-04 20:35:33 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Line continuation not working in VBA for 2D Array construction

(1 个回答)


2年前关闭。



varData = [{"Interbank Placement", "LIBOR/IB/COF"; "cat", "goku"; 4, "cow"; 6, "soccer"; "test", 8; "drinks", "goal"}]

我有这样的代码。它太长了,我想把它分成几行。我尝试了下面的代码,但它仍然说缺少括号。我怎样才能做到这一点?
    varData = [{"Interbank Placement", "LIBOR/IB/COF"; _ 
"cat", "goku"; 4, "cow"; 6, "soccer"; "test", 8; "drinks", "goal"}]

最佳答案

您可以使用 Evaluate在带有数组数据的字符串上 - 但前提是字符串被正确引用。这有点痛苦,但可能 - 见下文:

Option Explicit

Sub Test()

Dim strData As String
Dim varData As Variant

strData = "{""Interbank Placement"", ""LIBOR/IB/COF"";" & _
"""cat"", ""goku"";" & _
"4, ""cow"";" & _
"6, ""soccer"";" & _
"""test"", 8;" & _
"""drinks"", ""goal""}"

varData = Evaluate(strData)

MsgBox "varData is array of: " & UBound(varData, 1) & "x" & UBound(varData, 2)

End Sub

关于带有括号表达式的vba行继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43175304/

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