Using script to create a label on form?
Hi, this is a bit hard to explain.
I need help to script a label that will appear on the form. I dont mean just mean go into the editer and drag the label onto the form. I mean actually script it.
Like:
dim label1 as label()
label1.width = 300
etc... If you get what i mean.
Re: Using script to create a label on form?
Welcome to VBForums.
You'd have to create a NEW instance of the label class:
VB.NET Code:
Dim myLabel As New Label()
Then just set any properties you need and add it to the container you wish to hold it, commonly the form.
VB.NET Code:
myLabel.Text = "Hello world"
myLabel.Location = New Point(30, 30)
Me.Controls.Add(myLabel)
Re: Using script to create a label on form?
Aww man cheers. :)
That was doign my head in. Thanks
Re: Using script to create a label on form?
Isn't Dim myLabel as new Label() making a label array? I think he just wants one label..
Re: Using script to create a label on form?
Quote:
Originally Posted by noahssite
Isn't Dim myLabel as new Label() making a label array? I think he just wants one label..
Nope ;) Its calling the Label's empty constructor. You could remove the () and it'd work the same, but being used to the way C++/Java/C# works, I always write it like that.