本文介绍了如何更改 MsgBox 中的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改 MsgBox 中的字体?

How do you change font in a MsgBox?

X = MsgBox("I want this to be bold times new roman.")

推荐答案

你没有.通过 MsgBox 显示的对话框使用为系统对话框配置的字体.如果您需要自定义对话框,则需要构建自定义对话框,例如像这样:

You don't. The dialog displayed via MsgBox uses the font that is configured for system dialogs. If you need a custom dialog you need to build a custom dialog, e.g. like this:

Sub CustomMsgBox(msg)
  Set ie = CreateObject("InternetExplorer.Application")
  ie.Navigate "about:blank"

  While ie.ReadyState <> 4 : WScript.Sleep 100 : Wend

  ie.ToolBar   = False
  ie.StatusBar = False
  ie.Width     = 300
  ie.Height    = 120

  ie.document.body.innerHTML = "<p class='msg'>" & msg & "</p>" & _
    "<p class='ctrl'><input type='hidden' id='OK' name='OK' value='0'>" & _
    "<input type='submit' value='OK' id='OKButton' " &_
    "onclick='document.all.OK.value=1'></p>"

  Set style = ie.document.CreateStyleSheet
  style.AddRule "p.msg", "font-family:times new roman;font-weight:bold;"
  style.AddRule "p.ctrl", "text-align:rightf;"

  ie.Visible = True

  On Error Resume Next
  Do While ie.Document.all.OK.value = 0 
    WScript.Sleep 200
  Loop
  ie.Quit
End Sub

这篇关于如何更改 MsgBox 中的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 17:53