VBA:在运行时将TextBox添加到UserForm [英] VBA: Add TextBox to UserForm on Runtime

查看:309
本文介绍了VBA:在运行时将TextBox添加到UserForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在运行时添加文本框到我的用户窗体。
目前我正在使用以下代码:

I want to add textboxes on runtime to my user form. Currently I am doing this with this code:

Dim edtBox_n As Control
Set edtBox_n = usrFrm.Controls.Add("Forms.TextBox.1", "edtBox_n", True)
With edtBox_n
    .Top = 20
    .Left = 20
End With

但是,我无法处理多行,最大长度等文本框特定的文字。

However, I cannot manipulate textbox specific porperties like multiline, maxtext length etc.

是否有另一个选项在运行时添加控件到不具备此要求的用户?

Is there another option adding controls on runtime to a userfor which does not lack this requirement?

推荐答案

对于我来说(在Excel 2007中测试)完美无缺:

This works perfectly OK for me (tested on Excel 2007):

Dim edtBox_n As Control
Set edtBox_n = usrFrm.Controls.Add("Forms.TextBox.1", "edtBox_n", True)
With edtBox_n
    .Top = 20
    .Left = 20
    .MultiLine = True
    .EnterKeyBehavior = True
    .Height = 100
End With

这篇关于VBA:在运行时将TextBox添加到UserForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆