简体   繁体   中英

Bold font for MsgBox in Visual Basic

How to make font bold in a MessageBox in Visual Basic 2008?

I would like to have it like this:

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

where "Documentation" will be showing in a bold font.

As aphoria said, VB's MsgBox does not allow bold text. Here is how you work around that:

1) Add a "New Windows Form" 2) Add a RichTextBox 3) Add the # of CommandButtons you want/need 4) Go to the code for the form and do something like the following

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()

Hope that helps.

The built-in MsgBox function cannot do this. You will have to build your own if you really need it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM