关于清空件内容的问题.
Private Sub s_ClearControl()
On Error GoTo Err_Msg
Dim ctl As control
Dim nCount As Integer
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
ctl.Text = ""
ElseIf TypeOf ctl Is DTPicker Then
ctl.value = Date
ElseIf TypeOf ctl Is ComboBox Then
ctl.ListIndex = -1
End If
Next
Exit Sub
Err_Msg:
MsgBox(Err.Description)
End Sub
上面这段代码是VB中用于我清空TextBox ,ComboBox 三种控件的内容及对DTPicker控件进行初使化.现在要升成VB.net 后 trl.value=date 和ctl.ListIndex = -1
提示不是System.Windows.Forms.Control控件
下面是升成后的代码.有一点点改动了.
Private Sub s_ClearControl()
On Error GoTo Err_Msg
Dim ctl As System.Windows.Forms.Control
Dim nCount As Short
For Each ctl In Me.Controls
If ctl.Name = "TextBox" Then
ctl.Text = ""
ElseIf ctl.Name = "DateTimePicker" Then
ctl.value = Today
ElseIf ctl.Name = "ComboBox" Then
ctl.ListIndex = -1
End If
Next ctl
Exit Sub
Err_Msg:
MsgBox(Err.Description)
End Sub
各位大大有什么好的办法帮忙解决一下的....