簡體   English   中英

如何在vbnet中設置多行字符串變量

[英]How to set a multiline string variable in vbnet

我需要在變量中存儲多行字符串:

dim str as string = "
    some words
    some words
    some
    words
"

怎么樣?

無需使用類來插入新行,您可以這樣做:

Dim Logo As String= <a><![CDATA[
___  ___        _  _    _  _  _              
|  \/  |       | || |  (_)| |(_)             
| .  . | _   _ | || |_  _ | | _  _ __    ___ 
| |\/| || | | || || __|| || || || '_ \  / _ \
| |  | || |_| || || |_ | || || || | | ||  __/
\_|  |_/ \__,_||_| \__||_||_||_||_| |_| \___|


 _____  _          _                         
/  ___|| |        (_)                        
\ `--. | |_  _ __  _  _ __    __ _           
 `--. \| __|| '__|| || '_ \  / _` |          
/\__/ /| |_ | |   | || | | || (_| |          
\____/  \__||_|   |_||_| |_| \__, |          
                              __/ |          
                             |___/           
]]></a>.Value

Console.WriteLine(Logo)

VB.Net沒有這樣的功能,它也不會出現在Visual Studio 2010中。

在VB.NET中查看多行字符串以獲取解決方法

就這樣..

dim str as string = "some words" & vbCrlf & "some words" & vbCrlf & "some" & vbCrlf & "words"

或者嘗試使用vbLf

您可以像這樣使用XML

dim vrstr as string = <s>
    some words
    some words
    some
    words
</s>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM