Solved

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

Posted on 2007-03-30
2
152 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
2 Comments
 
LVL 142

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now