منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : ما هو اختصار هذه الاكواد
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .

السلام عليكم
مساء الخير
PHP كود :
 Private Sub clearAllTextBoxes(ctl As Control)
 
     If TypeOf ctl Is TextBox Then
          CType
(ctlTextBox).Clear()
 
     ElseIf ctl.HasChildren Then
          For Each c 
As Control In ctl.Controls
              If TypeOf c Is TextBox Then
                  CType
(cTextBox).Clear()
 
             ElseIf c.HasChildren Then
                  For Each h 
As Control In c.Controls
                      If TypeOf h Is TextBox Then
                          CType
(hTextBox).Clear()
 
                     End If
 
                 Next
              End 
If
 
         Next
      End 
If
 
 End Sub
  Private Sub fillAlltextBoxes
(ctl As Control)
 
     If TypeOf ctl Is TextBox Then
          CType
(ctlTextBox).Text ctl.Name
      ElseIf ctl
.HasChildren Then
          For Each c 
As Control In ctl.Controls
              If TypeOf c Is TextBox Then
                  CType
(cTextBox).Text c.Name
              ElseIf c
.HasChildren Then
                  For Each h 
As Control In c.Controls
                      If TypeOf h Is TextBox Then
                          CType
(hTextBox).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
(ctrlTextBox).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
(ctrlTextBox).Text ctrl.Name
          End 
If
 
     Next ctrl
  End Sub 
وجدت الكود ووضعته للفائدة.
مشاركة لكم :
PHP كود :
Private Sub ClearTextBoxes(ByVal ctrl As Control)
 
   Array.ForEach(ctrl.Controls.OfType(Of Control).ToArraySub(c) If TypeOf c Is TextBox Then c.Text "" Else ClearTextBoxes(c))
End Sub 

PHP كود :
Private Sub FillTextBoxes(ByVal ctrl As Control)
 
   Array.ForEach(ctrl.Controls.OfType(Of Control).ToArraySub(c) If TypeOf c Is TextBox Then c.Text c.Name Else FillTextBoxes(c))
End Sub 
ايه الفايده من FillTextBoxes
(10-11-23, 11:48 PM)Ashraf10 كتب : [ -> ]مشاركة لكم :
PHP كود :
Private Sub ClearTextBoxes(ByVal ctrl As Control)
 
   Array.ForEach(ctrl.Controls.OfType(Of Control).ToArraySub(c) If TypeOf c Is TextBox Then c.Text "" Else ClearTextBoxes(c))
End Sub 

PHP كود :
Private Sub FillTextBoxes(ByVal ctrl As Control)
 
   Array.ForEach(ctrl.Controls.OfType(Of Control).ToArraySub(c) If TypeOf c Is TextBox Then c.Text c.Name Else FillTextBoxes(c))
End Sub 
ايه الفايده من FillTextBoxes
ههههههههههههه
هذا فقط للسرعة عشان اجرب
(11-11-23, 12:10 AM)justforit كتب : [ -> ]
(10-11-23, 11:48 PM)Ashraf10 كتب : [ -> ]مشاركة لكم :
PHP كود :
Private Sub ClearTextBoxes(ByVal ctrl As Control)
 
   Array.ForEach(ctrl.Controls.OfType(Of Control).ToArraySub(c) If TypeOf c Is TextBox Then c.Text "" Else ClearTextBoxes(c))
End Sub 

PHP كود :
Private Sub FillTextBoxes(ByVal ctrl As Control)
 
   Array.ForEach(ctrl.Controls.OfType(Of Control).ToArraySub(c) If TypeOf c Is TextBox Then c.Text c.Name Else FillTextBoxes(c))
End Sub 
ايه الفايده من FillTextBoxes
ههههههههههههه
هذا فقط للسرعة عشان اجرب
بسم الله الرحمن الرحيم
كيف يمكن استدعاء هذه الدالة (ClearTextBoxes)
[/quote]
بسم الله الرحمن الرحيم
كيف يمكن استدعاء هذه الدالة (ClearTextBoxes)
[/quote]

           ClearTextBoxes(Me)

         FillTextBoxes(Form1)