looping with variable control name
I have this code:
VB Code:
For i = 1 To 4
For j = 0 To 4
SQLSTR = "INSERT INTO Coeff (CAL_ID, Curve_Order, Coeff, Coeff_Val) VALUES (" & CALID & ", " & i & ", " & j & ", " & frmRegression.txtCoefficient_ & i & (j) & ")"
CN.Execute (SQLSTR)
Next j
Next i
And what I'm trying to do is loop through sets of control arrays to store some variables. It's the following line that I have a problem with:
frmRegression.txtCoefficient_ & i & (j)
I need a way to make it look for that control array and then get that value from that control array. I know there has to be an easy way to do this.
Re: looping with variable control name
What exactly is the name of your control array and their indexes?
Re: looping with variable control name
You will need to use the Form's Controls collection.
Try the following
frmRegression.Controls("txtCoefficient_" & i)(j).Text