?
Solved

I have: Name of a button, and I want to change the text of it

Posted on 2007-03-30
2
Medium Priority
?
195 Views
Last Modified: 2010-04-23
I want to change the text of a button. What I know is the name of the button and the new text.

So I have tried this:

Private Sub me_text_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles me_text.TextChanged
        GetControl(me_control.Text).Text = me_text.Text
    End Sub

    Private Function GetControl(ByVal _Name As String) As Button
        Dim entry As Control
        For Each entry In Controls                                     'searching all controls
            If entry.GetType.Name = "Button" Then            'only search for name if its a button
                If entry.Name = _Name Then                         'if the button has the name of the button that I want
                    Return entry                                              'return entry, which is a button
                End If
            End If
        Next
    End Function

What is wrong?

Thanks

Sven
0
Comment
Question by:Ruttensoft
[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 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18822399
what error do you get?

maybe this works better:
 Private Function GetControl(ByVal _Name As String) As Button
        Dim entry As Control
        For Each entry In Controls                                     'searching all controls
            If entry.GetType.Name = "Button" Then            'only search for name if its a button
                If entry.Name = _Name Then                         'if the button has the name of the button that I want
                    Return entry as Button                                              'return entry, which is a button
                End If
            End If
        Next
    End Function
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 2000 total points
ID: 18822506
Hi Ruttensoft,

If you are using VS2005, you can use this....

     CType(Me.Controls.Find(me_control.Text, True)(0), Button).Text = me_text.Text

Else, you might like to take a look at this -> http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21564702.html

Regards,

Wayne
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

801 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