?
Solved

user control

Posted on 2004-10-15
5
Medium Priority
?
146 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 60 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 60 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 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