如何在VBA中的用户窗体文本框中添加提示横幅? [英] How do I add a cue banner to a userform textbox in VBA?
本文介绍了如何在VBA中的用户窗体文本框中添加提示横幅?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在VBA中创建了一个用户窗体,但是我希望在某些方框中提示提示横幅样式(如'DD / MM / YYYY'等)。我可以找到这个函数的VB.NET代码,但是找不到VBA解决方案。有什么想法吗?
我尝试了什么:
没那么多真的,在网上看了一下,但找不到任何东西
I am making a userform in VBA, but I want a cue banner style prompt (like 'DD/MM/YYYY', etc) in some of the boxes. I can find VB.NET code for this function, but cant find a VBA solution. Any ideas?
What I have tried:
Not that much really, looked on the internet a bit, but cant find anything
推荐答案
你需要发送EM_SETCUEBANNER
消息控制。
此代码在VB6中,但在VBA中运行起来应该不会太难:
< a href =http://vbnet.mvps.org/code/textapi/setcuebanner.htm> [VBnet Text API] SendMessage:使用提示横幅提示用户 [ ^ ]
You need to send theEM_SETCUEBANNER
message to the control.
This code is in VB6, but it shouldn't be too hard to get it working in VBA:
[VBnet Text API] SendMessage: Use Cue Banners to Prompt Users[^]
Private Const ECM_FIRST As Long = &H1500
Private Const EM_SETCUEBANNER As Long = (ECM_FIRST + 1)
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Public Sub SetCueBanner(ByVal hwnd As Long, ByVal banner As String)
banner = StrConv(banner, vbUnicode)
Call SendMessage(hwnd, EM_SETCUEBANNER, 0&, ByVal banner)
End Sub
如文章所述,您可能还需要调用 InitCommonControls
并向您的应用程序添加清单。但是,这可能不适用于VBA,具体取决于主机。
As mentioned in the article, you might also need to call InitCommonControls
and add a manifest to your application. However, that might not apply to VBA, depending on the host.
这篇关于如何在VBA中的用户窗体文本框中添加提示横幅?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文