Question Concatanation of a variable name

mr_sarge

New member
Joined
Jan 30, 2009
Messages
2
Programming Experience
Beginner
Hi,

Is it possible to do a concatanation of a variable name itself?

Ex:
I want to turn 5 variable to 0
VB.NET:
De1Lock = 0
De2Lock = 0
De3Lock = 0
De4Lock = 0
De5Lock = 0

I would like something like:
VB.NET:
For i = 1 To 5
De[i]Lock = 0
Next

Is There a way to do that in VB.Net ?

Thanks
 
I suspect this is possible using Reflection.

You may want to look at your program design if this is something that you plan on doing. An array or List(Of Integer) would be a much better choice in this situation.
 
Ok I have try:
VB.NET:
Public DeLock() As Integer = {1, 2, 3, 2, 1}

and do
VB.NET:
DeLock = New Integer() {0, 0, 0, 0, 0}

To reset it to zero.

Is there something better or this is ok ?

Anf If I want to do the same thing but with Label.Text ?
VB.NET:
        Form1.Label1.Text = "0"
        Form1.Label2.Text = "0"
        Form1.Label3.Text = "0"
        Form1.Label4.Text = "0"
        Form1.Label5.Text = "0"
 
Back
Top