有什么方法可以在 vb 或 vba 中对齐消息框中的文本吗?

发布于 2025-01-02 00:24:44 字数 66 浏览 0 评论 0原文

有什么方法可以将VB或VBA中的msgbox中的文本对齐到中心吗? VB 有没有类似的功能?

Is there any way to align text into the center in msgbox in VB or VBA? Does VB have any functionality to do the same?

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

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

发布评论

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

评论(7

放肆 2025-01-09 00:24:46

您可能可以在消息框中使用 vbtab 和 controlchars.CrLf 的组合。

you probably can use a combinatrion vbtab and controlchars.CrLf in the message box.

断肠人 2025-01-09 00:24:46

将 Application.Input 框“居中”很容易:当该框打开时,用鼠标将框移动到您希望它将来打开的位置,它就可以做到这一点。它会在您上次放置的位置打开。至少如此;它对我有什么作用。

It is easy to "center" an Application.Input box: When the box opens, with the mouse move the box where you want it to open in the future and it does just that. It opens where you last position it. At least that; what it does for me.

东北女汉子 2025-01-09 00:24:46

MsgBox([Put Your Text Here], MsgBoxStyle.Information & MessageBoxOptions.RightAlign)

I Trid 及其工作

MsgBox([Put Your Text Here], MsgBoxStyle.Information & MessageBoxOptions.RightAlign)

I Trid and Its Work

给我一枪 2025-01-09 00:24:45

不。 MsgBox() 函数只是 Windows MessageBox() 函数,因此对图标之外的对话框没有风格控制。

如果您想对其进行进一步更改,则需要创建自己的窗口并显示它。

在 Windows Vista+ 上,您可以使用 TaskDialogs 允许更多的控制。

No. The MsgBox() function is simply a wrapper for the Windows MessageBox() function and as such has no stylistic control over the dialog beyond the icon.

If you want to change it any further than this, you will need to create your own window and show that instead.

On Windows Vista+ you can use TaskDialogs that allow a lot more control.

独行侠 2025-01-09 00:24:45

不,但你可以通过使用空格来作弊。

msgbox("                your message")

no, but you can cheat by using spaces.

msgbox("                your message")
天生の放荡 2025-01-09 00:24:45

当您构建字符串时,您可以在它们的开头和结尾处填充空格以达到目标长度。如果您使用 Excel,则工作表函数 rept 对此非常方便。

function pad_n_center(byval mystring as string, lenmax as integer) as string
    dim pad_by as integer
    dim pad as string
    pad_by = (lenmax - len(mystring))/2
    'some more code to finesse that?
    pad = worksheetfunction.rept(" ",pad_by)
    pad_n_center = pad & mystring & pad
end function

如前所述,如果消息框仍然看起来不太好,您可以使用文本框形状对象(或其他对象)来获得所需的效果。

When you are building your strings you could pad them at the beginning and end with spaces to achieve a target length. If you're using excel the worksheet function rept is handy for this.

function pad_n_center(byval mystring as string, lenmax as integer) as string
    dim pad_by as integer
    dim pad as string
    pad_by = (lenmax - len(mystring))/2
    'some more code to finesse that?
    pad = worksheetfunction.rept(" ",pad_by)
    pad_n_center = pad & mystring & pad
end function

As mentioned before if the msgbox still doesn't look good you can use textbox shape object (or other objects) to get the desired effect.

来日方长 2025-01-09 00:24:45

VBA

一些注释: http://access.mvps.org/access/bugs/bugs0035.htm http://www.tek-tips.com/viewthread.cfm?qid=435428 不过,构建自己的消息框并不是那么困难,它可以解决您的所有问题。

VBA

Some notes: http://access.mvps.org/access/bugs/bugs0035.htm AND http://www.tek-tips.com/viewthread.cfm?qid=435428 However, it is not so difficult to build your own message box, which solves all your problems.

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