473,395 Members | 1,437 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,395 software developers and data experts.

use counter variable when referencing control

I'm learning vb, coming from a Perl background. I want to know how to
reference a form element by using a counter variable in the element's name.
For instance, let's say I have a form with 10 textboxes named textbox1
through textbox 10 and I have a for loop and I want to populate the text in
the textboxes with the numbers 1 through 10 and I want to reference the
textbox names by using the counter, something like this

for x = 1 to 10
textbox(x).text = x
next

what particular characters do I use around the x to tell vb I want it to
interpret the value of x and use it at the end of the form element's name?

Hopefully I'm explaining myself properly.

BTW, if anyone knows perl, it would be the vb equivalent of the { }
characters.

Any help would be greatly appreciated.
Nov 21 '05 #1
2 1585
"mdiddy" <md****@discussions.microsoft.com> schrieb:
I'm learning vb, coming from a Perl background. I want to know how to
reference a form element by using a counter variable in the element's
name.
For instance, let's say I have a form with 10 textboxes named textbox1
through textbox 10 and I have a for loop and I want to populate the text
in
the textboxes with the numbers 1 through 10 and I want to reference the
textbox names by using the counter, something like this

for x = 1 to 10
textbox(x).text = x
next

what particular characters do I use around the x to tell vb I want it to
interpret the value of x and use it at the end of the form element's name?

\\\
Private m_TextBoxes() As TextBox = {Me.TextBox1, Me.TextBox2, ...}
..
..
..
For Each txt As TextBox In m_TextBoxes
txt.Text = ...
Next txt
///

Accessing controls by their names or indices
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=controlbynameindex&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
"mdiddy" <md****@discussions.microsoft.com> schrieb:
I'm learning vb, coming from a Perl background. I want to know how to
reference a form element by using a counter variable in the element's
name.
For instance, let's say I have a form with 10 textboxes named textbox1
through textbox 10 and I have a for loop and I want to populate the text
in
the textboxes with the numbers 1 through 10 and I want to reference the
textbox names by using the counter, something like this

for x = 1 to 10
textbox(x).text = x
next

what particular characters do I use around the x to tell vb I want it to
interpret the value of x and use it at the end of the form element's name?

\\\
Private m_TextBoxes() As TextBox = {Me.TextBox1, Me.TextBox2, ...}
..
..
..
For Each txt As TextBox In m_TextBoxes
txt.Text = ...
Next txt
///

Accessing controls by their names or indices
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=controlbynameindex&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

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

Similar topics

1
by: [XaToA] | last post by:
Hello. I am trying to put one counter in my php with the next code: <?php $hitfile = "/admin/contador.txt"; if (!file_exists($hitfile)) { $file = fopen($hitfile,"r+"); $hits =...
2
by: Mike Brearley | last post by:
I have a counter (alright one I found on asp101.com) that checks for a session variable to prevent the counter from incrmenting if a user refreshes the page or returns to the page during the same...
0
by: timv | last post by:
Hi, i read an article on why it's not good to use getdlgitem in c++. Now, i have a dialog which contains a picture control. It is not possible in my visual studio .net to add a member control...
6
by: Who.Really.Really.Cares | last post by:
Hi! I guess this must be a FAQ but I'll give it a try. I've searched the web and usenet archive and found only negative answers. But most of them were dated like 3-4 years back. Hasn't anything...
1
by: KathyB | last post by:
Hi, sorry to be greedy with all my posts lately, but can you tell I'm doing new things this week? I've just done my first datalist (a simple one), that give me one column of records. I would...
0
by: mdiddy | last post by:
I'm learning vb, coming from a Perl background. I want to know how to reference a form element by using a counter variable in the element's name. For instance, let's say I have a form with 10...
1
by: beihotmailanmelden | last post by:
Hello, here's the situation: I have a banner on a third party page that, if you click on it, links to another third party page. I cannot install a counter on that thirdparty page. Is there...
9
by: Daniel Vukadinovic | last post by:
I want to implement an index/counter to my linked list. Why? I wrote a search function which searches the list for elements based on their values (say I add an element and I assign the value 54...
3
by: RSH | last post by:
Hi, I have a situation where I have a page built in .Net 1.1 that I have a PlaceHolder in the Design. From the CodeBehind I am dynamically referencing a user control. This is a snippet from...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.