My Photo
Location: Bangalore, India

Tips to Reduce Abdominal Fat!

Friday, October 28, 2005

Create Controls on the fly...

Create Controls at Run time in VB6

You can create a control at run time in vb6 and add it to a form. But to do this you should be aware of the progid of the control to be created. ProgIDs are defined as direct sub keys of the top-level HKEY_CLASSES_ROOT key in the registry. You set the properties of the controls once it is created.

The following function creates a Label object and add it to a form.

Public Sub addLabel(frmCurrent As Form)
Dim lblFoo As Label

Set lblFoo = frmCurrent.Controls.Add("VB.Label", "lblFoo")

With lblFoo
.Left = 100
.Top = 100
.Caption = "Just Created"
.Visible = True
End With
End Sub

Load Controls at Run time in VB6

To add controls at run time, there must already be at least one instance of the control on the form and it must be part of a control array.

When the program runs, you add additional controls with the Load statement: Load ControlName(Index).

ControlName refers to the Name property of the control array you created and Index is the Index property of the new control. You should start at 1 because Index 0 is already taken by the control you placed on the form at design time.

Each control that you add in this way initially has the same properties as the original control. You'll have to position the control to prevent all the added controls from displaying at the same position on screen and set visible property to True.


Blogger bloggrez said...

Davison Psyches Out Triangle
Bruce Davison, who co-stars as psychic Stan Lathem in the upcoming SCI FI Channel original miniseries The Triangle , told SCI FI Wire that he made first contact with executive producer Bryan Singer about the ...
Hey you've got a great blog here, the best I've seen so far, keep up the good job! A few days ago I was surfing the web and came across this cool site on Apply for loans online. It features all sorts of interesting information on Apply for loans online and makes it super easy to apply online. Now I know that people want fast services I recommend they visit Apply for loans online for quick and hassle-free service.

4:58 AM  
Blogger Sean Biggler said...

SUPER good job on this blog. I'm trying to learn how to get mine like this...
I've setup a normal website about swim shirt rashguards pretty good (just swim shirt rashguards stuff) but I'm really looking for some tips on my blog.

Come check me out on my blog if you get a chance...

5:04 AM  
Blogger agiptek said...

I want to make webbrowser control in vb6 on the fly
can I do this ?
Dim browser(5) As WebBrowser
Dim i As Integer
For i = 0 To 5
browser(i).Navigate "some url"
Next i

3:52 PM  

Post a Comment

<< Home