Results 1 to 5 of 5

Thread: Using script to create a label on form?

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    40

    Question 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.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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:
    1. 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:
    1. myLabel.Text = "Hello world"
    2. myLabel.Location = New Point(30, 30)
    3. Me.Controls.Add(myLabel)
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2008
    Posts
    40

    Re: Using script to create a label on form?

    Aww man cheers.

    That was doign my head in. Thanks

  4. #4
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    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..

  5. #5
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width