Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

Working with a VB control

I am wondering how you instatiate a vb conrtol through code

I need to use a label without actually placing one on a form I ws thiking it would be something like this but obviously it didn't work :-)

Dim lblLabel as Label

  Set lblLabel = new Label
 
  lblLabel.width = 400

0
pgarn
Asked:
pgarn
  • 2
1 Solution
 
bobbit31Commented:
Dim myLabel As Label
Set myLabel = Form1.Controls.Add("VB.Label", "myLabel")

myLabel.width = 400
0
 
Richie_SimonettiCommented:
and, if i am not wrong and you want to access events too:
dim withevents myLabel as label
0
 
pgarnAuthor Commented:
thnx great answer
0
 
bobbit31Commented:
your welcome :)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now