dumbpuppy
02-20-2008, 09:27 AM
OK. I proactively admit this post seems like beating the same drum with a different stick (Eval functionality).
The reason I’m posting this question is that this scenario comes up quite a bit and if I can figure out a better approach it will pay dividends not just when coding the routines initially but would yield a code base which can be more easily maintained.
In this case I have text fields on a form named txtBullPre1, txtBullPre2, txtBullPre3, txtBullPre4, and txtBullPre5.
I want to iterate through the fields capturing their values.
I would like the method to look something like this:
For i = 1 To 5
sSearchPhrase = eval(“frm90Review.txtBullPre” & i & “.Text)
'… more action here
Next i
Instead I am doing something like this
For i = 1 To 5
Select Case I
Case 1
sSearchPhrase = frm90Review.txtBullPre1.Text
Case 2
sSearchPhrase = frm90Review.txtBullPre2.Text
Case 3
sSearchPhrase = frm90Review.txtBullPre3.Text
Case 4
sSearchPhrase = frm90Review.txtBullPre4.Text
Case 5
sSearchPhrase = frm90Review.txtBullPre5.Text
End Select
'... more action here
Next i
I have successfully used logic similar to what I am looking for when the syntax supports a string as a parameter. Example Below:
For i = 1 To 9
Set oLine = ActivePresentation.Slides(SlideName).Shapes.AddLine( _
(i * 10 / 100 * dblNetWidth) + dblLeft, _
dblTop, (i * 10 / 100 * dblNetWidth) + dblLeft, dblTop + 5)
oLine.Line.Weight = 2
oLine.Fill.ForeColor.RGB = RGB(0, 0, 0)
oLine.Tags.Add "Progress", "tickline" & I
oLine.Line.Visible = msoTrue
Next i
If CallByName is the solution can someone help with the syntax necessary to work with text?
Thanks again for any assistance.
This Forum has been extremely helpful. :bow:
The reason I’m posting this question is that this scenario comes up quite a bit and if I can figure out a better approach it will pay dividends not just when coding the routines initially but would yield a code base which can be more easily maintained.
In this case I have text fields on a form named txtBullPre1, txtBullPre2, txtBullPre3, txtBullPre4, and txtBullPre5.
I want to iterate through the fields capturing their values.
I would like the method to look something like this:
For i = 1 To 5
sSearchPhrase = eval(“frm90Review.txtBullPre” & i & “.Text)
'… more action here
Next i
Instead I am doing something like this
For i = 1 To 5
Select Case I
Case 1
sSearchPhrase = frm90Review.txtBullPre1.Text
Case 2
sSearchPhrase = frm90Review.txtBullPre2.Text
Case 3
sSearchPhrase = frm90Review.txtBullPre3.Text
Case 4
sSearchPhrase = frm90Review.txtBullPre4.Text
Case 5
sSearchPhrase = frm90Review.txtBullPre5.Text
End Select
'... more action here
Next i
I have successfully used logic similar to what I am looking for when the syntax supports a string as a parameter. Example Below:
For i = 1 To 9
Set oLine = ActivePresentation.Slides(SlideName).Shapes.AddLine( _
(i * 10 / 100 * dblNetWidth) + dblLeft, _
dblTop, (i * 10 / 100 * dblNetWidth) + dblLeft, dblTop + 5)
oLine.Line.Weight = 2
oLine.Fill.ForeColor.RGB = RGB(0, 0, 0)
oLine.Tags.Add "Progress", "tickline" & I
oLine.Line.Visible = msoTrue
Next i
If CallByName is the solution can someone help with the syntax necessary to work with text?
Thanks again for any assistance.
This Forum has been extremely helpful. :bow: