vba 在消息框中显示 3 个值,值之间有空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17809506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Display 3 values in a message box with spaces between the values
提问by Pike7893
I am trying to display 3 values in a MsgBox
.
我试图在一个MsgBox
.
My logic statements are working, and it is picking the correct values I want - however I am unable to make my message box display 3 separate values with spaces between them.
我的逻辑语句正在工作,它正在选择我想要的正确值 - 但是我无法让我的消息框显示 3 个单独的值,它们之间有空格。
Problem: I need spaces between each value, as well as the middle value is not being displayed when i run this.
问题:我需要在每个值之间使用空格,并且在我运行它时没有显示中间值。
WW = MsgBox(Application.Worksheets("Assembly1").Range("A" & Z) & Application.Worksheets("Assembly1").Range("B" & Z) & Application.Worksheets("Assembly1").Range("D" & Z), vbOKOnly, "HEY YOU HAVE SOMETHING NEW")
回答by brettdj
Just use & " " &
between the values
只需& " " &
在值之间使用
ie
IE
Z = 1
WW = MsgBox(Application.Worksheets("Assembly1").Range("A" & Z) & " " & Application.Worksheets("Assembly1").Range("B" & Z) & " " & Application.Worksheets("Assembly1").Range("D" & Z), vbOKOnly, "HEY YOU HAVE SOMETHING NEW")
回答by JosieP
for interest you can also use
出于兴趣,您也可以使用
WW = MsgBox(Join(Application.Index(Worksheets("Assembly1").Range("A" & Z, "D" & Z), 0, Array(1, 2, 4)), " "), vbOKOnly, "HEY YOU HAVE SOMETHING NEW")
回答by Kamal G
or if you need line breaks then use msgbox ("A" & chr(10) & "B" & chr(10) & "C")
或者,如果您需要换行,则使用 msgbox ("A" & chr(10) & "B" & chr(10) & "C")
It will show output as:
它将显示输出为:
A
一种
B
乙
C
C
回答by rangan
The messages can be displayed in seperate lines which would be clear to read.
这些消息可以显示在单独的行中,这将是清晰的阅读。
WW = MsgBox(Application.Worksheets("Assembly1").Range("A" & Z) +Chr(13)+ Application.Worksh
Instead of spaces (& " "&) you can use either Chr(13) or vbcrlf in places where you want to introduce space. This would display the message in distinct different lines.
除了空格 (& " "&),您还可以在要引入空格的地方使用 Chr(13) 或 vbcrlf。这将在不同的行中显示消息。