问题
varData = [{"Interbank Placement", "LIBOR/IB/COF"; "cat", "goku"; 4, "cow"; 6, "soccer"; "test", 8; "drinks", "goal"}]
I have a code like this. It is too long and I would like to break it into lines. I tried the code below but it still says missing bracket. How can I do this?
varData = [{"Interbank Placement", "LIBOR/IB/COF"; _
"cat", "goku"; 4, "cow"; 6, "soccer"; "test", 8; "drinks", "goal"}]
回答1:
You can do it by using Evaluate on a string with the array data - but only if the strings are properly quoted. This is a bit of pain, but possible - see below:
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
来源:https://stackoverflow.com/questions/43175304/vba-line-continuation-with-bracket-expression