Visual Basic: Multiline Literals, Its the Strings, Really...
Author: jason
Date: 2019-05-03 10:39:05
Category: Technical

New in VB14 is strings that can go on more than one line!! Wowser...

So, I did a couple things in my Visual Studio 2017 to try getting this to work.

1. In the Project properties I set my framework to 4.5 or higher
2. In the NuGet Package Manager I added the Dot Net Compiler
3. In the Web Config (or App Config) I went looking for the Dot Net Compiler line for VB in the compiler keys and changed the /langversion:default to /langversion:14

Strange that it took VB this long to get multiline strings...

Unfortunately, you can't do that if you are using VBScript in Classic ASP. But, if you want multi-line strings (like for SQL queries) as they are easy to edit, and you can handle putting them in Text files, you can read the contents of a Text file into the string like this


Dim query
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("query.txt"), 1)
query = TRIM(f.ReadAll)

jason @ - - copyright 2009