У меня есть TabControl в форме с 4 вкладками. Каждая вкладка имеет несколько GroupBox. Каждый GroupBox имеет tableLayoutPanel. Каждый tableLayoutPanel имеет прагматически сгенерированный массив текстового поля. если флажок в tableLayoutPanel установлен пользователем, то будут генерироваться текстовые поля в соответствующей строке. Предположим, имя одного из моих текстовых массивов: txtMax (0), txtMax (1) ....... до txtMax (42). Мне нужно знать, сколько txtMax (?) (Вместе с индексным массивом) было сгенерировано и стало видимым. Я пробовал следующее:
Dim coutGene as integer = 0
Dim coutParameter as integer = 0
Dim indx As Integer
Dim cntl1, cntl2, cntl3 As Control
For Each cnn As TabPage In tabParameters.TabPages
cntl1 = DirectCast(cnn, TabPage)
For Each c2 As Control In cntl1.Controls
If TypeOf (c2) Is GroupBox Then
cntl2 = DirectCast(c2, GroupBox)
For Each c3 As Control In cntl2.Controls
If TypeOf (c3) Is TableLayoutPanel Then
cntl3 = DirectCast(c3, TableLayoutPanel)
For Each c4 As Control In cntl3.Controls
If TypeOf (c4) Is TextBox Then
Dim txt As TextBox = DirectCast(c4, TextBox)
If txt.Name.StartsWith("txtMax") Then
If txt.Visible = True Then
indx = CInt(Between(txt.Name, "(", ")"))
countGene = CInt(countGene + Val(txtGene(indx).Text))
countParameter = countParameter + 1
txtMax(indx).Tag = ""
End If
End If
End If
Next
End If
Next
End If
Next
Next
Function Between(value As String, a As String, b As String) As String
' Get positions for both string arguments.
Dim posA As Integer = value.IndexOf(a)
Dim posB As Integer = value.LastIndexOf(b)
If posA = -1 Then
Return ""
End If
If posB = -1 Then
Return ""
End If
Dim adjustedPosA As Integer = posA + a.Length
If adjustedPosA >= posB Then
Return ""
End If
' Get the substring between the two positions.
Return value.Substring(adjustedPosA, posB - adjustedPosA)
End Function
Но каждый раз, когда код не попадает внутрь l oop для этого условия Если txt.Name.StartsWith ("txtMax") Тогда
Я застрял здесь. Любая помощь будет высоко оценена. С уважением. Тарик