Group,
10 months ago I posed the same question as to how to programatically create the variable names via the loop. However I'm now in real need of doing this and I don't fully understand what each step of the syntax actually means and what it does. Therefore I need your help. Here is that original post: [https://www.daniweb.com/programming/software-development/threads/489038/loop-read-text-line-by-line-into-multiple-textboxes]
Here's what I currently have:
Dim txtProps As String
Dim i As Integer
txtProps = ""
Dim objReader As New System.IO.StreamReader(propFileName)
i = 1
If System.IO.File.Exists(propFileName) = True Then
Do While objReader.Peek() <> -1
txtProps = objReader.ReadLine()
If txtProps = "" Then
Exit Do
End If
If i = 1 Then
prop01 = txtProps
End If
If i = 2 Then
prop02 = txtProps
End If
If i = 3 Then
prop03 = txtProps
i = i + 1
Loop
The reality is when the original post was written, I only needed 20 variable to put my property numbers in. But I'm rewriting this to allow all of our properties to be udated at one time. This means I need to have 120 variables. The common denominator is the prefix of the variable (prop). But I will need to name them "prop01", "prop02", etc. up through "prop120".
In Reverend Jim's reply he writes the following code:
Dim data() As String = {"box1", "box2", "box3"}
For i = 0 To 2
Me.Controls("textBox" & (i + 1)).Text = data(i)
Next
What I'm not understanding is, the "Dim data() As String = {"box1", "box2", "box3"}". Since I'm wanting to create variables that start with the word "prop", what information do I put in the "{}"? Do I put {"prop01", "prop02", "prop03"}? Since I need to define upwards of 120 (and more in the future), do I have to list all 120 variables? This is where I'm getting lost. I'm not sure what "Dim data() As String = {"box1", "box2", "box3"}" really means and does. Nor do I understand "Me.Controls("textBox" & (i + 1)).Text = data(i)".
Can you help me?
As always, thanks for your help.
Don