-
Apr 23rd, 2012, 05:17 AM
#1
Thread Starter
New Member
Create a Label with code
Hello people!
I am trying to create a label using code. But I don't konw how.
I tried to use some code like:
Code:
Dim lbl_new as New Label
lbl_new.Location = New Point(10, 10)
but that didn't work.
Can anyone point me to a tutorial or explain how I can do this?
-
Apr 24th, 2012, 01:05 AM
#2
Thread Starter
New Member
Re: Create a Label with code
-
Apr 24th, 2012, 05:44 AM
#3
Re: Create a Label with code
as you did not explain what you are trying to achieve, or in what application, difficult for anyone to give answer
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 24th, 2012, 11:24 AM
#4
Thread Starter
New Member
Re: Create a Label with code
Oh, well i was just trying to just create a normal label with code instead of having to make it in the design mode. Like when I press a button a label with like the text from a textbox I have.
And the application is Word 2007, but I just use the Visual Basic function not Word itself. Kinda hard to explain since I'm not too good with this stuff.
So just create a label with code is the only thing I want. Thankful for any help
-
Apr 25th, 2012, 06:09 AM
#5
Re: Create a Label with code
is this on a userform?
if so it should be something like
vb Code:
Set newlbl = Me.Controls.Add("Forms.Label.1", "mylabel", True) newlbl.Caption = "this is a test" newlbl.Left = 20 newlbl.Top = 40
this works, much easier to make the labels in design mode
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 25th, 2012, 07:07 AM
#6
Thread Starter
New Member
Re: Create a Label with code
Yes thank you! That was exactly what I wanted
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
|