' These strings are used to identify which type of control I'm looking at
Const boxNoOfBridgesIDString As String = "NoOfBridges"
Const firstBridgingIDString As String = "txtBridginga"
Const secondBridgingIDString As String = "txtBridgingb"
Const thirdBridgingIDString As String = "txtBridgingc"
Const labelNoIDString As String = "Label"
' Global declaration so they are accessable when I need them
Dim boxNoOfBridges() As ComboBox
Dim txtFirstBridge() As TextBox
Dim txtSecondBridge() As TextBox
Dim txtThirdBridge() As TextBox
Dim labelNo() As Label
Private Sub setupBridging()
Dim boxcount = 0
Dim txtfirstcount = 0
Dim txtsecondcount = 0
Dim txtthirdcount = 0
Dim labelcount = 0
For Each ctl As Control In TableBridging.Controls
If (ctl.Name.Length > boxNoOfBridgesIDString.Length) Then
If (ctl.Name.Substring(0, boxNoOfBridgesIDString.Length) = boxNoOfBridgesIDString) Then
ReDim Preserve boxNoOfBridges(boxcount)
boxNoOfBridges(boxcount) = ctl
boxcount += 1
End If
End If
If (ctl.Name.Length > firstBridgingIDString.Length) Then
If (ctl.Name.Substring(0, firstBridgingIDString.Length) = firstBridgingIDString) Then
ReDim Preserve txtFirstBridge(txtfirstcount)
txtFirstBridge(txtfirstcount) = ctl
txtfirstcount += 1
'MsgBox("Init: " + ctl.Name)
End If
End If
If (ctl.Name.Length > secondBridgingIDString.Length) Then
If (ctl.Name.Substring(0, secondBridgingIDString.Length) = secondBridgingIDString) Then
ReDim Preserve txtSecondBridge(txtsecondcount)
txtSecondBridge(txtsecondcount) = ctl
txtsecondcount += 1
End If
End If
If (ctl.Name.Length > thirdBridgingIDString.Length) Then
If (ctl.Name.Substring(0, thirdBridgingIDString.Length) = thirdBridgingIDString) Then
ReDim Preserve txtThirdBridge(txtthirdcount)
txtThirdBridge(txtthirdcount) = ctl
txtthirdcount += 1
End If
End If
If (ctl.Name.Length > labelNoIDString.Length) Then
If (ctl.Name.Substring(0, labelNoIDString.Length) = labelNoIDString) Then
ReDim Preserve labelNo(labelcount)
labelNo(labelcount) = ctl
labelcount += 1
End If
End If
Next
' At this point, for some reason, txtThirdBridge() is in reverse
End Sub