For i = 0 To Forms.Count - 1 If Forms(i).hWnd = yourHandle Then MsgBox Forms(i).Name Exit For End If Next i
你的forms是什么,集合,我怎么找不到,难道要自己记录
forms 是 VB 内部集合。使用就是了。Private Sub Form_Click() Load Form2 Load Form3 yourHandle = Form2.hWndFor i = 0 To Forms.Count - 1 If Forms(i).hWnd = yourHandle Then MsgBox Forms(i).Name Exit For End If Next i
If Forms(i).hWnd = yourHandle Then
MsgBox Forms(i).Name
Exit For
End If
Next i
Load Form2
Load Form3
yourHandle = Form2.hWndFor i = 0 To Forms.Count - 1
If Forms(i).hWnd = yourHandle Then
MsgBox Forms(i).Name
Exit For
End If
Next i
Unload Form2
Unload Form3
End Sub