I was wondering if it is possible to point to a textbox created in the form designer via a string variable. Basically, I'm creating a golf management system with a feature allowing a user to define their own course. Each hole has a corresponding textbox into which a user can input the hole's par and then the system should total up the first 9 pars, the last 9 pars and then all 18 pars; displayed in 3 different textboxes.
The input textboxes have been named txtP1, txtP2, ..., txtP18, so I was wondering if I could simply concatenate a loop control variable onto a constant of "txtP" to point to each input box.
This is what I have at the moment, but it's throwing up errors saying that .text is not a member of string.
Sub UpdatePar() Dim inpar, outpar, totalpar As Integer Dim pointer As String For hole = 1 To 18 pointer = "txtP" + Str(hole) If hole <= 9 Then outpar += Cint(pointer.text) End If If hole >= 10 Then inpar += Cint(pointer.text) End If totalpar = inpar + outpar txtIn.Text = inpar txtOut.Text = outpar txtTotalPar.Text = totalpar Next End Sub
Is there a way to achieve this in Express 2008? Any help would be greatly appreciated.