2

如何在 Visual Basic 2008 的 MessageBox 中使字体加粗?

我想要这样:

MsgBox(Documentation: .........) 

其中“文档”将以粗体显示。

4

2 回答 2

4

正如 aphoria 所说,VB 的 MsgBox 不允许粗体文本。以下是您解决此问题的方法:

1) 添加“新 Windows 窗体” 2) 添加 RichTextBox 3) 添加您想要/需要的命令按钮数 4) 转到表单的代码并执行以下操作

Public Sub CustomMessageBox(ByVal msg As String, ByVal isBold As Boolean, ByVal color As System.Drawing.Color, ByVal buttonOneText As String, ByVal buttonTwoText As String, ByVal startBoldAt As Integer = 0, ByVal endBoldAt As Integer = 0)
 ' Use parameters to pass the values you want to show
 ' startBoldAt will be the position in the string where you want to have bold lettering begin, and endBoldAt will be the position in the string where you want bold lettering to end.
End Sub

Then you can do:  
Dim cmb as CustomMessageBox = New CustomMessageBox('Your parameters)
' Add a sub that will let you show the CustomMessageBox
cmb.Show()

希望有帮助。

于 2013-02-12T20:42:14.013 回答
1

内置MsgBox函数无法做到这一点。如果你真的需要它,你将不得不建立自己的。

于 2013-02-12T20:10:22.017 回答