【问题标题】:Use MessageBoxW to simulate Msgbox for Unicode display. Need unicode for Inputbox使用 MessageBoxW 模拟 Msgbox 进行 Unicode 显示。输入框需要 unicode
【发布时间】:2020-01-18 23:06:20
【问题描述】:

Access Msgbox 不支持 Unicode 字符。我用MessageBoxW来模拟Msgbox,效果很好。

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 显示信息并提供预设按钮供用户选择。 InputBox 允许用户输入字符串。

不知道可以用哪个函数来模拟InputBox来支持Unicode字符数据的输入。谢谢。

【问题讨论】:

标签: ms-access


【解决方案1】:

从来没想过,但我的InputMox(和MsgMox)似乎支持Unicode。

这里列出的代码太多,但完整的代码在 GitHub 上:VBA.ModernBox

测试

使用代码:

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

【讨论】:

  • 他们没有,至少在我尝试过的任何系统上都没有。它们确实支持您当前代码页中的所有字符,因此要对其进行测试,您需要使用 ChrW 尝试在代码页之外显示字符。
  • @ErikA:我就是这么做的。请看示例。
  • 我的意思是,经典的,不是你的,你的很好,只是风格不同
  • 复制的代码,它似乎工作。需要弄清楚如何设置 ModernBox 和 ModputBox 表单。
  • @YellowLarry:不需要“设置”。这两个函数是其 VBA 祖先的直接替换。
猜你喜欢
  • 2016-05-05
  • 2017-12-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-02
  • 2011-07-06
  • 2023-03-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多