Solved

user control

Posted on 2004-10-15
5
145 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 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