473,654 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1597
"mdiddy" <md****@discuss ions.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=controlbyna meindex&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****@discuss ions.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=controlbyna meindex&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
4596
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 = fread($file,filesize($hitfile)); fclose ($file); }
2
1992
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 session. The problem is, it also prevents other page counters from incrementing. Here's the code for this part: ' Increment the count if Session("iCount") <> iCount then iCount = iCount + 1 Session("iCount") = iCount
0
1333
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 variable (i want to add a cstatic variable referencing the picture control). When i click 'ok' in the add member variable wizard, visual studio just closes the wizard, but the variable is not added. Did this happen to someone before? Does someone...
6
74170
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 changed since then? DB2 V7.2. The problem: I have a table with a primary key GENERATED BY DEFAULT AS IDENTITY. Then I INSERT several rows and force their PK's value. Then I see that my INSERTs haven't modified the value of DB2's internal IDENTITY
1
1718
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 like to put the total count of the rows into the control's footer. I couldn't find any references for doing this and ended up trying several things, one of which was assigning a variable within the sub creating the datalist control, and when that...
0
293
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 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...
1
2136
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 any service that will allow me to count how many times someone has clicked on my banner, by inclusion of some code and a service that allows me to see the stats?
9
4040
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 and the next element 789 and so on...) now I'd like to write a search function which would search the list for elements based on their index. Say first element is 54 and index 1, second element is 789 and index 2 so when I want to search, I'll do...
3
4293
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 the the CodeBehind from that page: Dim mc As MainContent = New MainContent <----User Created Control
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8482
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.