Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6 Runtime
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
 
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!
Posted 25-Jun-12 16:07pm
Edited 25-Jun-12 16:21pm
v3
Comments
Sergey Alexandrovich Kryukov at 25-Jun-12 21:11pm
   
Is there any single reason to deal with this garbage called "VB6" at all? And even ask questions about it?
--SA
Himachandra at 29-Jun-12 3:43am
   
No sense at all.....
Y you are giving unreasonable suggestions....
If you know ans regarding ques...... then give it other wise
*******
Sergey Alexandrovich Kryukov at 29-Jun-12 18:00pm
   
Well, this is you who think this suggestion is unreasonable (even though it was just a question, suggestive, perhaps). I'm sure VB6 makes no sense at all. Do you see any single reason to use it? :-)
--SA
satrio_budidharmawan at 25-Jun-12 21:14pm
   
Yeah,
I don't know why, but there're many student still VB6-ing on their Final Project, that's too shame..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
'
  Permalink  
Comments
satrio_budidharmawan at 26-Jun-12 2:15am
   
how if I need to create a lot of textbox (say it 100 of textbox)?
Do I need to
Dim cmd1 to cmd100?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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!!!!
  Permalink  
Comments
satrio_budidharmawan at 2-Jul-12 21:16pm
   
Nope, you forget the terms "Dynamically"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 535
1 OriginalGriff 275
2 BillWoodruff 260
3 Shweta N Mishra 244
4 Deepu S Nair 230
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,818
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,755


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 27 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100