- To pass a string as a control name, you can use:
ParentControl.Controls("ControlName")
. - To pass a string as an application setting name, you can use:
My.Settings("SettingName")
.
Hence, your code should look something like the following:
For i = 301 To 305 Step 1
My.Settings("h" & i.ToString) = Me.Controls("TextBox" & i.ToString).Text
Next
Please note that if the parent of your textboxes is not the form, you’ll need to replace Me
with the parent control name.
Hope that helps 🙂
0
solved Using variable in for next loop code