Clear ค่า Object ต่างๆ ทุกตัวใน GroupBox
คำสั่งด้านล่างนี้เอาไว้สำหรับ Clear ค่าใน Object Type ต่างๆ ที่วางอยู่ใน GroupBox ครับ เช่น TextBox, RadioButton, ComboBox, NumericUpDown ถ้าอยากเพิ่มอีก ก็เพิ่มได้เลยครับดูจากตัวอย่างน่าจะพอเข้าใจ
แล้วก็ค่าที่ Sub Program นี้รับมาจะเป็น GroupBox ครับ ถ้าเราอยากรับเป็นอย่างอื่นอะไรก็เปลี่ยนตามใจครับ
Private Sub ClearForm(ByRef oGroupBx As GroupBox) Dim i, intTemp As Integer intTemp = oGroupBx.Controls.Count For i = 0 To intTemp - 1 With oGroupBx.Controls 'TextBox If .Item(i).GetType() Is GetType(TextBox) Then With CType(.Item(i), TextBox) .Clear() End With End If 'RadioButton If .Item(i).GetType() Is GetType(RadioButton) Then With CType(.Item(i), RadioButton) .Checked = False End With End If 'ComboBox If .Item(i).GetType() Is GetType(ComboBox) Then With CType(.Item(i), ComboBox) .SelectedIndex = -1 End With End If 'NumericUpDown If .Item(i).GetType() Is GetType(NumericUpDown) Then With CType(.Item(i), NumericUpDown) .Value = 0 End With End If End With Next End Sub
Comments(0)