0

Access Msgbox does not support Unicode character. I use MessageBoxW to simulate Msgbox and it works perfectly.

Private Declare PtrSafe Function MessageBoxW Lib "User32" (ByVal hWnd As LongPtr, ByVal lpText As LongPtr, ByVal lpCaption As LongPtr, ByVal uType As Long) As Long

Public Function MsgBoxW(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional Title As String = "Microsoft Access") As VbMsgBoxResult
    Prompt = Prompt & vbNullChar 'Add null terminators
    Title = Title & vbNullChar
    MsgBoxW = MessageBoxW(Application.hWndAccessApp, StrPtr(Prompt), StrPtr(Title), Buttons)
End Function

MsgBox display information and provides preset buttons for user selection. InputBox allows user to enter string.

Do not know which function I can use to simulate InputBox to support Unicode character data entering. Thanks.

YellowLarry
  • 383
  • 1
  • 4
  • 16
  • Does this answer your question? [How do I display a messagebox with unicode characters in VBA?](https://stackoverflow.com/questions/55210315/how-do-i-display-a-messagebox-with-unicode-characters-in-vba) – June7 Jan 18 '20 at 23:52
  • It is for MsgBox which I use now. I need equivalent function of InputBox to enter Unicode character. – YellowLarry Jan 19 '20 at 01:58

3 Answers3

0

Never thought about it, but my InputMox (and MsgMox) seems to support Unicode.

Too much code to list here, but full code is on GitHub: VBA.ModernBox

Test

Using the code:

MsgMox InputMox("Enter Unicode", "Unicode Test", ChrW(453)), vbInformation + vbOKOnly, "Unicode Test"

enter image description here

enter image description here

Gustav
  • 53,498
  • 7
  • 29
  • 55
  • They don't, at least not on any system I tried. They do support all characters in your current code page, so to test it you need to use `ChrW` to try to display a character outside your code page. – Erik A Jan 19 '20 at 09:21
  • @ErikA: That's what I did. See examples, please. – Gustav Jan 19 '20 at 11:56
  • I mean, the classic ones, not yours, yours are fine just a very different style – Erik A Jan 19 '20 at 15:05
  • Copied code and it seems work. Need to figure out how to setup ModernBox and ModputBox forms. – YellowLarry Jan 19 '20 at 15:05
  • @YellowLarry: No "setup" is needed. The two functions are direct replacements for their VBA ancestors. – Gustav Jan 19 '20 at 16:15
0

Try Application.InputBox(). It's different from InputBox(). This should work since about 2010.

Tam Le
  • 360
  • 3
  • 17
0

Thanks Tam Le for this.

Particularly useful using the Application.InputBox object instead of just InputBox. (As the Application.InputBox object allows you to use more optional arguments). While it isn't very well documented what the additional "Type" argument's values can be, that was the secret to solving this problem. Setting the "Type" argument to "2" allowed my input boxes to display Unicode characters, including Greek ones! It changes the look of the input box slightly (prettier in my opinion), but made it function way better in terms of how it can handle every character needed. For example:

'' Application.InputBox(Prompt,[Title],[Default],[Left],[Top],[Default],[HelpFile],[HelpContextID],[Type])

' So I was able to use either this way:

myStringToInput = Application.InputBox("SomeUnicodeTextOfAnyCharactersInMyPrompt","SomeUnicodeTextOfAnyCharactersInMyOptionalTitle", , , , , 2)

' Or this way:

myStringToInput = Application.InputBox(Prompt:="SomeUnicodeTextOfAnyCharacters",Title:="SomeUnicodeTextOfAnyCharacters",Type:=2)