I have those labels inside a table therefore I cannot combine them.
Those labels are called lbl1, lbl2, lbl3 and lbl4
I have a dataset containing some data I found
my loop looks like this
Dim starttime as Integer
Dim i As interger
Dim count as Integer = 900
Dim x as Integer =9
while count < 2401
startTime = result1.table("BookedPet").Rows(i).items("StartTime")
if startTime = count
lbl(x).text = "booked" <--- this is for lbl1 / lbl2 and lbl3
End If
x =x + 1
count = count +100
i =i +1
End While
what youre saying is, you have 4 variables, like these strings:
Dim s1, s2, s3, s4 As String
and then you want to make a loop and somehow access their in-code names via the loop:
VB.NET:
For i as Integer = 1 to 4
s[B][i][/B] = "hello"
Next
Can i just make one thing clear:
Ignoring reflection, no precompiled programming language has ever, nor will ever offer this functionality. You cannot use one variable value to reference the name of another variable in your code!!
Those variable names are lost when the code is compiled so they arent even called s1, s2, s3 any more..
in java, it's not like... sorry but it cannot be done.
What I suggest you do is use an array. in your case, an array of labels:
Dim myLabels(0 to 3) as Label
myLabels(0) = lbl1
myLabels(1) = lbl2
myLabels(2) = lbl3
myLabels(2) is the array(with index)
lbl3 is the name of the label in normal code..
both are pointers to an object in memory that is a label on screen. They point to the same place. Once can be accessed with a numeric indexer. One cannot.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.