2010-07-11 67 views
0

字符串我試圖指派以下HTML作爲值變量類型的字符串申報HTML標籤在VB.NET

'here's the tag 
    '$("#close").click(function(){$.notifyBar({ html: "Click 'close' to hide notify bar", close: true, delay: 1000000 });}); 

     Dim htmltag = "$("#close").click(function(){$.notifyBar({ html: "Click 'close' to hide notify bar", close: true, delay: 1000000 });});" 

我得到的字符串中的報價很多的錯誤消息。

回答

0

您需要在引號中使用轉義字符,否則會打斷變量輸入。該VB.net逃逸報價是雙引號:

Dim htmltag = "$(""#close"").click(function(){$.notifyBar({ html: ""Click 'close' to hide notify bar"", close: true, delay: 1000000 });});" 

在您的例子,編譯器會看到字符串:

Dim htmltag = "$(" 

上面有很多未知的東西后!

其他語言有不同的轉義字符,例如javascript是反斜槓。