Solved

user control

Posted on 2004-10-15
5
144 Views
Last Modified: 2010-05-02
Hello, I am putting together a control that gets and sets the labels text. I am putting this functionality within the name property below:

Private dname As String

 Property name1() As String
        Get
            name1 = dname
        End Get
        Set(ByVal Value As String)
            dname = Label1.Text
        End Set

    End Property

I want to set the label name within control in the implementation program, and not sure how to do it and if my property is looking right at all?
0
Comment
Question by:Gipsy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:Gipsy
ID: 12318158
I would want to set the controls label in the form_load  event :
   
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load


End Sub
0
 
LVL 5

Assisted Solution

by:jmacmicking
jmacmicking earned 20 total points
ID: 12318167
If I'm understanding what you want correctly your Set statement should look something like this:

Set(ByVal Value as String)
    dname=Value
    Label1.Text=dname
End SEt

You could do away with dname entirely, just use Label1.Text in your Get statement as well.

A couple of points though:  
    .Text is a property of a textbox, it sets or gets the text typed into the textbox.  If you're using a label control the equivalent property is .Caption--this sets the text the user of your program sees.
    The name of a control (label or otherwise) is set at design time or, in the case of a dynamically generated control, Dim'd at run time.  I'm assuming you're trying to set either the Text property of a textbox or the Caption property of a label.

If you're control is a label this would be the Set property:

Set(ByVal Value as String)
    dname=Value
    Label1.Caption=dname
End SEt

0
 

Author Comment

by:Gipsy
ID: 12318234
Thanks,

But i cant get it to work in implementation,

I want to put smth like this

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

usercontol.name1() = "Start of the month"

End Sub
0
 
LVL 10

Expert Comment

by:fds_fatboy
ID: 12318598
jmacmicking:

Gipsy is using vb.NET (not mentioned - but you can tell because of the Property statement layout) therefore, Label1.Text is correct, not Label1.Caption.
0
 
LVL 10

Accepted Solution

by:
fds_fatboy earned 20 total points
ID: 12318656
You can get rid of dName and try changing your Property to this:

Public Property name1() As String
        Get
            name1 = Label1.Text
        End Get
        Set(ByVal Value As String)
            Label1.Text = Value
        End Set

    End Property

I haven't got dotNet here, at work so I can't test it.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question