?
Solved

control name as text

Posted on 2004-10-10
3
Medium Priority
?
202 Views
Last Modified: 2010-04-23
i know this is farily easy, but i dont know what to search for

im wanting to control a bunch of different controls, and i dont want to use a control array...what i want to do is pass the text which will be the name

so something along the lines of

"text1".Text

thanks

~b
0
Comment
Question by:bramsquad
[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
3 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 12273004
You can use something like this:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim objTB As TextBox

        objTB = FindControl("TextBox1")
        If Not (objTB Is Nothing) Then
            objTB.Text = "Surpise!"
        Else
            MessageBox.Show("Control not found!")
        End If
    End Sub

    Function FindControl(ByVal pName As String) As Control
        For Each x As Control In Me.Controls
            If x.Name.ToUpper = pName.ToUpper Then
                Return x
            End If
        Next
    End Function
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12273013
Maybe this way,

Dim oControl As Control
   For Each oControl In Me.Controls
     If oControl.Name = "TextBox1" Then
        Exit For
     End If
Next

' oControl is the control that you searching
MsgBox(oControl.Text)
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12273028
Sorry, That was concurrency :D
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
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