I have a form that contains 10 text boxes labeled CPTCodeBox_x (where x = 1 to 10). On form load I want to set the values to 0. Instead of using 10 lines of code and setting each value to zero I am trying to use a For Next Loop with an embedded with/end with. However, I am getting an error that reads "WITH OBJECT MUST BE USER-DEFINED TYPE, OBJECT, OR VARIANT"
Code:
Dim q As Integer, boxname(1 To 10) As String
For q = 1 To 10
boxname(q) = "CPTCodeBox_" & q
With boxname(q)
.Value = 0
End With
Next q
Bookmarks