|
-
Oct 17th, 2008, 05:30 AM
#1
Thread Starter
Member
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.
-
Oct 17th, 2008, 05:37 AM
#2
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)
-
Oct 17th, 2008, 05:43 AM
#3
Thread Starter
Member
Re: Using script to create a label on form?
Aww man cheers. 
That was doign my head in. Thanks
-
Oct 17th, 2008, 06:15 AM
#4
Frenzied Member
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..
-
Oct 17th, 2008, 06:17 AM
#5
Re: Using script to create a label on form?
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|