以TextBox 的GotFocus和、LostFocus事件为例,让FORM中的两个TextBox用同样的事件。 1、建一个类,名为ClassFocus,类代码如下: Private WithEvents TextBox As TextBox Public Sub SetTextBox(vData As TextBox) Set TextBox = vData End Sub Private Sub TextBox_GotFocus() TextBox.BackColor = &HC0FFC0 TextBox.SelStart = 0 TextBox.SelLength = Len(TextBox.Text) End Sub Private Sub TextBox_LostFocus() TextBox.BackColor = &H80000005 End Sub 2、Form代码如下: Dim txt(2) As New ClassFocus Private Sub Form_Load() txt(0).SetTextBox Textbox1 txt(1).SetTextBox Textbox2 End Sub