Best way to define a large vba string - i.e. heredoc equivalent?

后端 未结 3 1209
花落未央
花落未央 2020-12-10 02:34

How should I define large strings in VBA? Is there a better way than coding something like the below?

Dim largeString as String
largeString = \"This is a lon         


        
3条回答
  •  感情败类
    2020-12-10 03:17

    Another way is to store the text in comments, then parse it in a function. No external files required, good readability.

    ' TEXT to retrieve:
    '   SELECT
    '   field1, field2
    '   FROM table1
    
    Function SQL_in_comments()
        SQL_in_comments = Replace(Replace(Application.VBE.ActiveCodePane.CodeModule.Lines(2, 3), "'   ", ""), "'", "")
    End Function
    

提交回复
热议问题