Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
AnswerRe: Genericize access to variables [modified] Pin
Paul Michalik1-Sep-10 11:47
Paul Michalik1-Sep-10 11:47 
GeneralRe: Genericize access to variables Pin
AspDotNetDev1-Sep-10 11:51
protectorAspDotNetDev1-Sep-10 11:51 
AnswerRe: Genericize access to variables Pin
Łukasz Nowakowski1-Sep-10 20:14
Łukasz Nowakowski1-Sep-10 20:14 
AnswerRe: Genericize access to variables Pin
Alexander Voronin2-Sep-10 1:52
Alexander Voronin2-Sep-10 1:52 
AnswerRe: Genericize access to variables Pin
ExportedNorwegian2-Sep-10 2:01
ExportedNorwegian2-Sep-10 2:01 
AnswerRe: Genericize access to variables Pin
Dave Buhl2-Sep-10 3:11
Dave Buhl2-Sep-10 3:11 
AnswerRe: Genericize access to variables Pin
JaceTheAce2-Sep-10 4:12
JaceTheAce2-Sep-10 4:12 
AnswerRe: Genericize access to variables Pin
RMcEachern2-Sep-10 10:37
RMcEachern2-Sep-10 10:37 
How to do this is quite simple, but not obvious since we do not normally think of dimensioning a variable as a control type.

The simplest way (to me) is to dimension an array of labels, Label(1), Label(2) etc. as Label. Then set each member of the array equal to each of the labels you want to control a property for.

Then you can write a loop setting a property of each label in the array as an iterated function, such as:

Dim Label(1) as Label
Dim Label(2) as Label ...

Label(1) = LabelA
Label(2) = LabelB ...

For x = 1 to 5
Label(x).text = "Text " & x
Next

(Sorry, I am an old VB.NET programmer, but the concept is the same in all Big Grin | :-D )

I think this is what you want, works great for me, and works for the other common controls, too.
AnswerRe: Genericize access to variables Pin
coolguy19882-Sep-10 15:09
coolguy19882-Sep-10 15:09 
QuestionDo you know which office outlook 2003 component can be sign into Microsoft Exchange Server via outlook? Pin
milestanley1-Sep-10 1:44
milestanley1-Sep-10 1:44 
Questionquestion Pin
bitayekta1-Sep-10 0:51
bitayekta1-Sep-10 0:51 
AnswerRe: question Pin
Pete O'Hanlon1-Sep-10 1:05
mvePete O'Hanlon1-Sep-10 1:05 
AnswerRe: question Pin
Smithers-Jones1-Sep-10 5:12
Smithers-Jones1-Sep-10 5:12 
GeneralRe: question Pin
Pete O'Hanlon1-Sep-10 7:45
mvePete O'Hanlon1-Sep-10 7:45 
GeneralRe: question Pin
AspDotNetDev1-Sep-10 9:16
protectorAspDotNetDev1-Sep-10 9:16 
AnswerRe: question Pin
Eddy Vluggen1-Sep-10 8:38
professionalEddy Vluggen1-Sep-10 8:38 
AnswerRe: question Pin
Dave Kreskowiak1-Sep-10 8:58
mveDave Kreskowiak1-Sep-10 8:58 
QuestionTrying to update sql table from datagrid Pin
mpanger1-Sep-10 0:31
mpanger1-Sep-10 0:31 
AnswerRe: Trying to update sql table from datagrid Pin
OriginalGriff1-Sep-10 6:16
mveOriginalGriff1-Sep-10 6:16 
GeneralRe: Trying to update sql table from datagrid Pin
mpanger1-Sep-10 7:20
mpanger1-Sep-10 7:20 
QuestionCasting a session object to a generic object Pin
Swiftain31-Aug-10 23:23
Swiftain31-Aug-10 23:23 
AnswerRepeat Pin
Not Active1-Sep-10 1:44
mentorNot Active1-Sep-10 1:44 
GeneralRe: Repeat Pin
Swiftain1-Sep-10 2:35
Swiftain1-Sep-10 2:35 
GeneralRe: Repeat Pin
Pete O'Hanlon1-Sep-10 3:09
mvePete O'Hanlon1-Sep-10 3:09 
GeneralRe: Repeat Pin
Swiftain1-Sep-10 2:36
Swiftain1-Sep-10 2:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.