Friend Sub resetFormControls(zForm As Form)
サブルーチンを試して、すべてのコントロールを未使用の状態にリセットしてください:空白のテキストボックス、チェックされていないチェックボックス、ラジオボタンなど。
For Each zCntl As Control In zForm.Controls
If zCntl.HasChildren Then
For Each zChildCntl As Control In zCntl.Controls
If zChildCntl.GetType Is GetType(CheckBox) Then
CType(zChildCntl, CheckBox).Checked = False
End If
If zChildCntl.GetType Is GetType(TextBox) Then CType(zChildCntl, TextBox).Text = ""
If zChildCntl.GetType Is GetType(TextBox) Then CType(zChildCntl, TextBox).BackColor = Color.White
If zChildCntl.GetType Is GetType(RichTextBox) Then CType(zChildCntl, RichTextBox).Text = ""
If zChildCntl.GetType Is GetType(RichTextBox) Then CType(zChildCntl, RichTextBox).BackColor = Color.White
If zChildCntl.GetType Is GetType(RadioButton) Then CType(zChildCntl, RadioButton).Checked = False
Next
End If
If zCntl.GetType Is GetType(CheckBox) Then CType(zCntl, CheckBox).Checked = False
If zCntl.GetType Is GetType(TextBox) Then CType(zCntl, TextBox).Text = ""
If zCntl.GetType Is GetType(TextBox) Then CType(zCntl, TextBox).BackColor = Color.White
If zCntl.GetType Is GetType(RichTextBox) Then CType(zCntl, RichTextBox).Text = ""
If zCntl.GetType Is GetType(RichTextBox) Then CType(zCntl, RichTextBox).BackColor = Color.White
If zCntl.GetType Is GetType(RadioButton) Then CType(zCntl, RadioButton).Checked = False
If zCntl.GetType Is GetType(DateTimePicker) Then CType(zCntl, DateTimePicker).Text = Now.Date
If zCntl.GetType Is GetType(ComboBox) Then CType(zCntl, ComboBox).SelectedIndex = 0
Next
Application.DoEvents()
Catch ex As Exception
End Try
End Sub