473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

change text property to various textbox

how do i change the text property to a lot of textbox if all textbox are
calle textbox1, textbox2 .... instead of doing it one bye one, i mean
something like

for i as integer = 0 to 10

textbox & i .text = i

next i
Jun 27 '08 #1
2 1256
On Wed, 28 May 2008 19:46:00 -0700, Sergio
<Se****@discussions.microsoft.comwrote:
>how do i change the text property to a lot of textbox if all textbox are
calle textbox1, textbox2 .... instead of doing it one bye one, i mean
something like

for i as integer = 0 to 10

textbox & i .text = i

next i
If they are all children of a form or some other container:

For Each ctl As Control In Me.Controls
If ctl Is Textbox Then ' This will do all textboxes
ctl.Text = "something"
End If
Next
Jun 27 '08 #2
Sergio wrote:
how do i change the text property to a lot of textbox if all textbox are
calle textbox1, textbox2 .... instead of doing it one bye one, i mean
something like

for i as integer = 0 to 10
textbox & i .text = i
next i
You don't.
Finding Controls by name is a pain in .Net. Far better to use the
facilities of the [new] language.

Use a list of TextBoxes, load each of your individual TextBoxes (each
with its own, /meaningful/ name) into it, then loop through the list, as
in:

Private tbList As New ArrayList
' VB'2005 and later can use "List(Of TextBox)"

Sub New()
InitializeControls()

tbList.Add( textbox1 )
tbList.Add( textbox2 )
. . .
End Sub

Sub Button1_Click( ... ) Handles Button1.Click
For Each tb as TextBox in tbList
tb.Text = ""
Next
' or, from your example
For iSub as Integer = 0 To tbList.Count - 1
tbList( iSub ).Text = iSub.ToString()
Next
End Sub

HTH,
Phill W.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change...
0
by: Jeff User | last post by:
I have my datagrid running pretty much with a EditCommandColumn and some TemplateColumn columns. There are two types of appearance changes I would like to make programatically from my C# code...
4
by: Dean Slindee | last post by:
Anyone got a quick and easy way to change the background color on a textbox after the user has change the text value. Already have lots of forms written, so an approach that does not depend on...
5
by: agarwasa2008 | last post by:
Hi, I have a linked table called tbltest and some bounded forms (which add, update, delete records) that were created using that linked table. For some necessary reasons I had to create another...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.