在运行时VB6上创建文本框(对象) [英] Create Textbox (Object) on runtime VB6

查看:176
本文介绍了在运行时VB6上创建文本框(对象)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有人知道如何使用VB6在运行时创建对象(如文本框,命令按钮,标签等)?

我的意思是当我点击一个按钮或执行任何操作,然后会出现新的文本框。



在VB.Net中看起来像这样

Hi,
Does anyone know how to create object (like textbox, command button, label, and so on) on runtime with VB6?
I means that when I clicked one button or do any action, then new textbox will appear.

In VB.Net look like this

Dim txt as New Textbox





但在VB6中不知道什么是新..



非常感谢



更新:我打算从头开始创建新对象,因此我们不会使用任何已创建的对象。 << ---如果你知道我的意思,那就是Control Array!



But in VB6 don't know what's "New"..

Many Thanks

update : I intended to create new object from scratch, so we won't use any object that had been create then. <<--- If U know what I means, it's Control Array!

推荐答案

在运行时动态创建一个Control。不使用控制阵列。那就是控制在设计时不存在但是会在运行时出现。



Create a Control dynamically at Run time. Without using a Control Array. That is the control is not present at Design time But will appear at Run Time.

option Explicit
'
Dim withevents Cmd1 as CommandButton
'
private Sub Form_Load()
set Cmd1 = Controls.Add("vb.commandbutton", "Cmd1")
Cmd1.Width = 2000
Cmd1.Top = me.Height / 2 - Cmd1.Height / 2 - 100
Cmd1.Left = me.Width / 2 - Cmd1.Width / 2 - 100
Cmd1.Caption = "Dynamic Button"
Cmd1.Visible = true
End Sub
'
private Sub Cmd1_click()
MsgBox "I have been Created Dynamically at Run-time", _
, "Dynamic Controls"
End Sub
'


为什么不创建文本框并将其设置在任何位置,并将其可见性属性设置为false,然后根据您想要的任何内容说另一个按钮单击您将其设置为可见。只是一个想法!!!!
Why don't you create the Textbox and set it wherever you want and set it's visibility property to false, then based on whatever you want say another button click that you set it to visible. Just a thought!!!!


这篇关于在运行时VB6上创建文本框(对象)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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