0

无论如何都引用函数或私有子本身而不影响另一个?使用“我”运算符对我不起作用,因为请参阅主窗口

Private Function comboclean() As Boolean
    ???.items.clear()
return nothing
End function

Private Sub nAdult_SelectedIndexChanged(sender As Object, e As EventArgs) Handles   nAdult.SelectedIndexChanged
    comboclean()
End Sub

Private Sub nJunior_SelectedIndexChanged(sender As Object, e As EventArgs) Handles nJunior.SelectedIndexChanged
    comboclean()
End Sub
4

2 回答 2

3

你在找这样的东西吗?我假设您要清除调用ComboBox,我创建了一个函数,该函数接受SelectedIndexChanged发送者对象并将其传递给函数。

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
    comboclean(DirectCast(sender, ComboBox))
End Sub

Private Function comboclean(combo As ComboBox) As Boolean
    combo.Items.Clear()
    Return Nothing
End Function
于 2013-09-22T01:11:53.093 回答
0

我想你想要这样的东西......一个功能清除了所有的组合框。

Private Sub comboclean()
    nAdult.items.clear()
    nJunior.items.clear()
End Sub

否则,您需要将要清除的控件传递给子例程。这样的事情可能会奏效。

Private Sub comboclean(TheList as Web.UI.WebControls.ListControl)
    TheList.items.clear()
End Sub

Private Sub nAdult_SelectedIndexChanged(sender As Object, e As EventArgs) Handles   nAdult.SelectedIndexChanged
    comboclean(sender)
End Sub

Private Sub nJunior_SelectedIndexChanged(sender As Object, e As EventArgs) Handles nJunior.SelectedIndexChanged
    comboclean(sender)
End Sub
于 2013-09-22T01:12:41.970 回答