|
有正途不走
以下是引用一点通在2005-12-22 10:19:00的发言:
呵呵,有点象是出试题一样
设定一个变量,当List1获得焦点及失去焦点时改变变量的值,并同时Call Command1,
在Command1命令按钮事件中用IF根据变量值情况执行不同的代码.
Public BLListFocus As Boolean
Private Sub List1_GotFocus()
BLListFocus = True
End Sub
Private Sub List1_LostFocus()
BLListFocus = False
End Sub
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
Screen.PreviousControl.SetFocus '这句是关键,当去按command1时,list或其他控件就已发生失去焦点事件,所以要先回到前物件的控制
MsgBox BLListFocus
if BLListFocus then
a
else
b
end if
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox err.Description
Resume Exit_Command1_Click
End Sub
|
|