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

Referring to a control with variables?

I've got a situation where I'm trying to refer to a control in terms of a counter.

I've got a 4x4 grid of labels, uniformly named according to their position in the grid, I.E. lbl00, lbl01, lbl02, lbl03, lbl10, lbl11, etc.

I'd like to refer to these controls with counters so that I don't have to have 16 case statements, in a theoretical fashion such as this:

For n = 0 to 3
For 0 = 0 to 3
ControlName = "lbl" & cstr(n) & cstr(o)
AssignValue(ControlName)
Next
Next

In other words, I want to refer to a control by constructing a string. That's where I hit a wall. Is there a way to convert that string into some sort of reference to a control?

Thanks for your help!

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 21 '05 #1
3 929
"M Sutherland" <ta******@hotmail.com> schrieb:
In other words, I want to refer to a control by constructing a string.


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
Hmm.. more complex than I thought it would be.

Thanks

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 21 '05 #3
M,

I am curious, what is difficult on that sample?

For n = 0 to 3
For 0 = 0 to 3
ControlName = "lbl" & cstr(n) & cstr(o)
AssignValue(ControlName)
Next
Next

\\\
For n = 0 to 3
For m = 0 to 3
For Each ctr As Control In me.Controls
If ctr.Name = "lbl" & cstr(n) & cstr(o) then
AssignValue(ControlName, n, m)
end if
Next ctr
Next
Next
///
This is when your labels are direct on the form, when they are by instance
on a panel is the only difference instead of me.Controls it becomes
panelx.Controls

When you do not know where they are you need the complete sample from
Herfried.

Everything typed in this message so watch typos or other errors

I hope this helps?

Cor
Nov 21 '05 #4

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

Similar topics

4
by: Daniel Pope | last post by:
Dear All, I'm developping a PH application that needs to know the refering URL (and the IP address) of a php script I mean the URL of a webpage that contains a link towards my php script. As I...
4
by: MLH | last post by:
Somehow, I seem to be able to refer to combo-box controls in 2 distinctly different ways. A combo-box on an Access 97 form named TagCountyChooserBox seems can be referenced these ways... ...
1
by: Terri | last post by:
I'm trying to create an INSERT statement that inserts records where one of the values should refer to a from control. INSERT INTO dbo_CheckRequestPayments ( FundCode, CheckRequestID ) SELECT...
2
by: tantiboh | last post by:
I've got a situation where I'm trying to refer to a control in terms of a counter. I've got a 4x4 grid of labels, uniformly named according to their position in the grid, i.e. lbl00, lbl01, lbl02,...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
3
by: Dan Sikorsky | last post by:
How can I get the Querystring passed to the Referring Page from its referrer? I don't want the querystring coming to my current page. I want the querystring that came to the referring page, so...
1
by: Paul Bromley | last post by:
Can someone tell me if there is any way of doing this? As an example - let us say that I have a button called cmdLetter and a textbox called txtLetter, can I in some way manipulate the names of...
1
by: pradeep_TP | last post by:
Hello everybody, I have created a web site which has a simple user control (LogoDisplay.ascx). This is part of a separate project called CommonControls. I have a main Project "MainProj" from...
60
by: Dave | last post by:
I'm never quite sure whether to use "this." or not when referring to fields or properties in the same class. It obviously works just fine without it but sometimes I wonder if using this....
4
by: CG | last post by:
Hi I need to implement some low level security that locks a certain page if the user does come from a particular link (which is hosted on another domain). I've considered using HTTP_REFERER...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
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,...
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,...

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.