هذا الكود يقوم فجمع قيم TextBox لكل TabPage
ويضع الناتج في Label الموجود في نفس TabPage
For Each pg As TabPage In TabControl1.TabPages
Dim lbl As Label = pg.Controls.OfType(Of Label)().First
Dim tot As Single = 0
For Each tb As TextBox In pg.Controls.OfType(Of TextBox)()
If String.IsNullOrEmpty(tb.Text.Trim) Then
tb.BackColor = Color.Red
Else
tb.BackColor = Color.White
End If
tot += Val(tb.Text)
Next
lbl.Text = tot
Next
ويضع الناتج في Label الموجود في نفس TabPage
For Each pg As TabPage In TabControl1.TabPages
Dim lbl As Label = pg.Controls.OfType(Of Label)().First
Dim tot As Single = 0
For Each tb As TextBox In pg.Controls.OfType(Of TextBox)()
If String.IsNullOrEmpty(tb.Text.Trim) Then
tb.BackColor = Color.Red
Else
tb.BackColor = Color.White
End If
tot += Val(tb.Text)
Next
lbl.Text = tot
Next
