10-11-23, 08:31 PM
السلام عليكم
مساء الخير
PHP كود :
Private Sub clearAllTextBoxes(ctl As Control)
If TypeOf ctl Is TextBox Then
CType(ctl, TextBox).Clear()
ElseIf ctl.HasChildren Then
For Each c As Control In ctl.Controls
If TypeOf c Is TextBox Then
CType(c, TextBox).Clear()
ElseIf c.HasChildren Then
For Each h As Control In c.Controls
If TypeOf h Is TextBox Then
CType(h, TextBox).Clear()
End If
Next
End If
Next
End If
End Sub
Private Sub fillAlltextBoxes(ctl As Control)
If TypeOf ctl Is TextBox Then
CType(ctl, TextBox).Text = ctl.Name
ElseIf ctl.HasChildren Then
For Each c As Control In ctl.Controls
If TypeOf c Is TextBox Then
CType(c, TextBox).Text = c.Name
ElseIf c.HasChildren Then
For Each h As Control In c.Controls
If TypeOf h Is TextBox Then
CType(h, TextBox).Text = h.Name
End If
Next
End If
Next
End If
End Sub
كما ترون بالكود حلقات متداخلة فهل توجد طريقة تختصر هذه الاكواد؟
PHP كود :
Private Sub ClearTextBoxes(ByVal root As Control)
For Each ctrl As Control In root.Controls
ClearTextBoxes(ctrl)
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Text = String.Empty
End If
Next ctrl
End Sub
Private Sub fill(ByVal root As Control)
For Each ctrl As Control In root.Controls
fill(ctrl)
If TypeOf ctrl Is TextBox Then
CType(ctrl, TextBox).Text = ctrl.Name
End If
Next ctrl
End Sub