带有括号表达式的vba行连续 [英] vba line continuation with bracket expression
本文介绍了带有括号表达式的vba行连续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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"}]
推荐答案
您可以通过对包含数组数据的字符串使用Evaluate
来做到这一点-但前提是必须正确引用字符串.这有点痛苦,但是可能-见下文:
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
这篇关于带有括号表达式的vba行连续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文