新建From1(窗体),新建Command1-2(按钮CommandButton),代码:
Private Sub Command1_Click()
Call s_IsFocus
End Sub
Private Sub Command2_Click()
Call s_IsFocus
End Sub
Private Sub s_IsFocus()
If Form1.ActiveControl Is Command2 Then 'Command2是被判断的控件
MsgBox "有焦点"
Else
MsgBox "无焦点"
End If
End Sub
当然也可以用timer控件不断检查。