如何在 VB msgbox() 中使用 \n 新行...?

发布于 2024-10-19 20:04:04 字数 59 浏览 2 评论 0原文

MsgBox()\n(换行)的替代方案是什么?

What is the alternative to \n (for new line) in a MsgBox()?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(17

你曾走过我的故事 2024-10-26 20:04:04
  • 对于 VB: vbCrLfvbNewLine
  • 对于 VB.NET: Environment.NewLinevbCrLfConstants.vbCrLf

有关 VB.NET 新行的信息:http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx

Environment.NewLine 来自 Cody GrayJ Vermeire

  • for VB: vbCrLf or vbNewLine
  • for VB.NET: Environment.NewLine or vbCrLf or Constants.vbCrLf

Info on VB.NET new line: http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx

The info for Environment.NewLine came from Cody Gray and J Vermeire

笑忘罢 2024-10-26 20:04:04

尝试使用 vbcrlf 作为换行符

msgbox "This is how" & vbcrlf & "to get a new line"

Try using vbcrlf for a newline

msgbox "This is how" & vbcrlf & "to get a new line"
陈年往事 2024-10-26 20:04:04

这些是创建新行的字符序列:

  • vbCr 是回车符(返回到行开头),

  • vbLf 是换行符(转到下一行)

  • < p>vbCrLf 是回车/换行(类似于按 Enter)

我更喜欢vbNewLine,因为它与系统无关vbCrLf在某些系统上可能不是真正的新行)

These are the character sequences to create a new line:

  • vbCr is the carriage return (return to line beginning),

  • vbLf is the line feed (go to next line)

  • vbCrLf is the carriage return / line feed (similar to pressing Enter)

I prefer vbNewLine as it is system independent (vbCrLf may not be a true new line on some systems)

恋竹姑娘 2024-10-26 20:04:04

添加 vbNewLine 为:

"text1" & vbNewLine & "text2"

Add a vbNewLine as:

"text1" & vbNewLine & "text2"
鹿港巷口少年归 2024-10-26 20:04:04

Environment.NewLine 的替代方法是使用 :

Regex.Unescape("\n\tHello World\n")

from System.Text.RegularExpressions

这允许您转义文本,而无需像在 C#、C、java 中那样连接字符串

An alternative to Environment.NewLine is to use :

Regex.Unescape("\n\tHello World\n")

from System.Text.RegularExpressions

This allows you to escape Text without Concatenating strings as you can in C#, C, java

只为一人 2024-10-26 20:04:04

正确的格式是:

"text1" + vbNewLine + "text2"

The correct format is :

"text1" + vbNewLine + "text2"
追我者格杀勿论 2024-10-26 20:04:04

使用命令“vbNewLine”

示例

Hello & vbNewLine & "World"

将显示为
一行是“Hello”,另一行是“World”

Use the command "vbNewLine"

Example

Hello & vbNewLine & "World"

will show up as
Hello on one line and World on another

汹涌人海 2024-10-26 20:04:04

您可以使用Environment.NewLinevbCrLFvbNewLine

MsgBox($"Hi!{Environment.NewLine}I'M HERE")

You can use Environment.NewLine OR vbCrLF OR vbNewLine

MsgBox(
quot;Hi!{Environment.NewLine}I'M HERE")
指尖微凉心微凉 2024-10-26 20:04:04

您可以使用回车符 (Chr(13))、换行符 (Chr(10)) 也如

MsgBox "Message Name: " & objSymbol1.Name & Chr(13) & "Value of BIT-1: " & (myMessage1.Data(1)) & Chr(13) & "MessageCount: " & ReceiveMessages.Count

You can use carriage return character (Chr(13)), a linefeed character (Chr(10)) also like

MsgBox "Message Name: " & objSymbol1.Name & Chr(13) & "Value of BIT-1: " & (myMessage1.Data(1)) & Chr(13) & "MessageCount: " & ReceiveMessages.Count
你爱我像她 2024-10-26 20:04:04
Module MyHelpers
    <Extension()>
    Public Function UnEscape(ByVal aString As String) As String

       Return Regex.Unescape(aString)

    End Function
End Module

用法:

console.writeline("Ciao!\n".unEscape)
Module MyHelpers
    <Extension()>
    Public Function UnEscape(ByVal aString As String) As String

       Return Regex.Unescape(aString)

    End Function
End Module

Usage:

console.writeline("Ciao!\n".unEscape)
仅冇旳回忆 2024-10-26 20:04:04

在我这边,我创建了一个子 MyMsgBox,用 ControlChars.NewLine 替换提示中的 \n

On my side I created a sub MyMsgBox replacing \n in the prompt by ControlChars.NewLine

时间你老了 2024-10-26 20:04:04

上面的很多东西对我来说都不起作用。
最终的工作是什么

Chr(13)

A lot of the stuff above didn't work for me.
What did end up working is

Chr(13)
记忆之渊 2024-10-26 20:04:04

不要忘记在文本框中将 Multiline 属性设置为 true

do not forget to set the Multiline property to true in textbox

看海 2024-10-26 20:04:04

msgbox("your text here" & Environment.NewLine & "more text") 是最简单的方法。没有必要让你的代码变得比你需要的更难或更复杂......

msgbox("your text here" & Environment.NewLine & "more text") is the easist way. no point in making your code harder or more ocmplicated than you need it to be...

海之角 2024-10-26 20:04:04

这对我来说工作:
MessageBox.Show("YourString" & vbcrlf & "YourNewLineString")

This work for me:
MessageBox.Show("YourString" & vbcrlf & "YourNewLineString")

财迷小姐 2024-10-26 20:04:04

消息框必须以文本结尾,不能以变量结尾

The message box must end with a text and not with a variable

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文