Greater than or equal to symbol in vba string msgbox

Huhenyo

Board Regular
Joined
Jun 11, 2008
Messages
138
All, I've been doing quite a few searches and I can't seem to find out how to put a ≥ symbol into a msgbox. I can find all sorts of threads on putting it into a cell, but chrW($H2265) doesn't work in a vba string. For instance this code:
Code:
msgbox chrW(&H2265)

just outputs =. Have any of you been able to put a ≥ into a vba string for output to the user in a message box?

Thank you for your help!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
The VBA standard Msgbox is in fact a wrapper for the MessageBoxA API function and as such, it converts all strings that are passed in its arguments from Unicode to Ansi that's why the caracter is not displayed

In order to avoid this unwanted string conversion, we should pass the String Pointer of the unicode character (instead of passing the actual character) to an Alias of the MessageBox API

The MyMsgBox Function below is actually a wrapper for the API Alias ... I kept the prototype definition of the MyMsgBox function in line with the standard VBA Msgbox for easy use ( except the optional HelpFile and Context arguments)

Example:

Code:
Option Explicit

#If VBA7 Then
     Declare PtrSafe Function MyMsgBoxAlias Lib "user32" Alias "MessageBoxW" (ByVal hwnd As LongPtr, ByVal lpText As LongPtr, Optional ByVal lpCaption As LongPtr, Optional ByVal wType As Long = 0) As Long
#Else
     Declare Function MyMsgBoxAlias Lib "user32" Alias "MessageBoxW" (ByVal hwnd As Long, ByVal lpText As Long, ByVal lpCaption As Long, ByVal wType As Long) As Long
#End If


Function MyMsgBox(ByVal Prompt As String, Optional ByVal Buttons As VbMsgBoxStyle, Optional ByVal Title As String = vbNullChar) As VbMsgBoxResult
    MyMsgBox = MyMsgBoxAlias(0, StrPtr(Prompt), StrPtr(Title), Buttons)
End Function


Sub Test()
    Dim s As String
    s = ChrW(&H2265)
    MyMsgBox s, , "Test"
End Sub
 
Last edited:
Upvote 0
The messagebox is a Windows feature that is shared by all Windows applications. Consequently, you would change the font by editing the Windows appearance settings. However, be aware that the changed font will apply to all message boxes in all Windows applications on the PC you change.

An Excel alternative would be to create a custom userform and change the font on the object that displays the message.

Is that something you can work with?
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top