0

I want to have multi line string in vb.net, This work fine when i use my code in button click, but when i move it to module i receive an error. Here it is the code:

Dim strTest As String = "Hi,
Welcome to my test
How you are you?"

It work fine in my button click, but in module i receive this error : Error Image

BC30648: String constants must end with a double quote.

I know i can use vbCrLf end of my text and append my second line but i have 50 text like this which i want to move in module. This code work in module :

Dim strTest As String = "Hi," + vbCrLf +
"Welcome To my test" + vbCrLf +
"How you are you?"

UPDATE : after i close and reopen my project now i can see error in "Dim strTest" with this massage :

Error BC36716 Visual Basic 12.0 does not support multiline string literals.

I use VS 2015 and this project is .Net framework 4.5

Ali P
  • 1
  • 2
  • 1
    I believe that multiline string literals in VB is a Roslyn feature and your screenshot suggests that that code is being compiled at run time, thus not by the Roslyn compiler. In that case, you need the code somewhere that is going to be compiled when you build, so that the Roslyn compiler is used. Before you think of asking what Roslyn is, MSDN would be the place to search for that information. – jmcilhinney Aug 19 '17 at 15:38
  • 1
    Possible duplicate of [Multiline strings in VB.NET](https://stackoverflow.com/questions/706382/multiline-strings-in-vb-net) – GSerg Aug 19 '17 at 17:01
  • @GSerg i saw this but i didn't find my answer, as i understand it should be fine in VS 2015 which i have, but i receive error – Ali P Aug 19 '17 at 18:12
  • @jmcilhinney So what can i do? i didn't find anything about multiline string doesn't work in module because of Roslyn – Ali P Aug 19 '17 at 18:22
  • Apparently you need to [enable Roslyn separately for Razor views](https://stackoverflow.com/q/39976506/11683). – GSerg Aug 19 '17 at 18:24
  • @GSerg My project is asp.net webform, I don't use anything except all default feature, no razor, ajax or json used – Ali P Aug 19 '17 at 18:28
  • @AliP I believe that does not change much. Also see https://stackoverflow.com/q/27968963/11683 and https://stackoverflow.com/q/33740123/11683. – GSerg Aug 19 '17 at 18:29
  • I haven't read it but your answer may be here: https://blogs.msdn.microsoft.com/webdev/2014/05/12/enabling-the-net-compiler-platform-roslyn-in-asp-net-applications/ – jmcilhinney Aug 19 '17 at 18:32
  • 1
    @jmcilhinney Thank you, Microsoft.CodeDom.Providers.DotNetCompilerPlatform nuget package fix the problem, it would be nice if you submit this as answer, maybe help someone else – Ali P Aug 19 '17 at 18:50
  • @GSerg Thank you too, Problem solved by your links – Ali P Aug 19 '17 at 18:52

0 Answers0