我打算在一个段落中断行。
是否有\n
打破字符串中的行?
Dim info As String = "Page name \n Date and Time" & DateTime.Now.ToString("yyyy-MM-dd, HH:mm:ss") & "\n Printed By Admin"
答案 0 :(得分:2)
使用Environment.NewLine
Dim info As String = "Page name " & Environment.NewLine _
& " Date and Time" _
& DateTime.Now.ToString("yyyy-MM-dd, HH:mm:ss") _
& Environment.NewLine & " Printed By Admin"
或XML literals或Embed Expressions
Dim info As String = <info>
Page name
Date and Time <%= DateTime.Now.ToString("yyyy-MM-dd, HH:mm:ss") %>
Printed By Admin
</info>.Value
或者,如果您在循环中创建字符串,则可以使用StringBuilder
Dim info As New StringBuilder()
info.AppendLine("Page name")
info.Append("Date and Time ")
info.AppendLine(DateTime.Now.ToString("yyyy-MM-dd, HH:mm:ss"))
info.AppendLine("Printed By Admin")
方法.AppendLine("text")
会在给定字符串的末尾添加Environment.NewLine
答案 1 :(得分:1)
使用 vbLf
Dim info As String = "Page name " & vbLf & " Date and Time" & DateTime.Now.ToString("yyyy-MM-dd, HH:mm:ss") & "" & vbLf & " Printed By Admin"