vba 用户窗体回车行为

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1183380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:38:01  来源:igfitidea点击:

vba userforms carriage return behavior

vbaexcel-vbanewlinecarriage-returnuserform

提问by stanigator

In a textbox of a userform in VBA, I would like to enable the feature where the user can add a new line in the textbox by pressing the "Enter" key on the keyboard. However, I had trouble finding a UI option in the UI editor to achieve this. Is this even allowed in VBA userforms? Thanks in advance for the advices and answers.

在 VBA 中用户窗体的文本框中,我想启用用户可以通过按键盘上的“Enter”键在文本框中添加新行的功能。但是,我无法在 UI 编辑器中找到 UI 选项来实现此目的。这在 VBA 用户表单中甚至允许吗?预先感谢您的建议和答案。

回答by shahkalpesh

Set textbox's MultiLine property to True and EnterKeyBehavior to True.

将文本框的 MultiLine 属性设置为 True,将 EnterKeyBehavior 设置为 True。

回答by ScaleOvenStove

have you tried incorporating the rich text control for text? Not sure how well it works with VBA, but in VB6 this is what I would use.

您是否尝试过为文本合并富文本控件?不确定它与 VBA 的配合情况如何,但在 VB6 中这就是我会使用的。