读书人

VBSCRIPT简单又很奇怪的Function相关有

发布时间: 2012-02-23 22:01:36 作者: rapoo

VBSCRIPT简单又很奇怪的Function相关问题

VBScript code
Dim Shell, win, hWndSet Shell = CreateObject("Shell.Application")Set win = Shell.windowsDim ieset ie =  GetfocusHwnd()Delay 3000MessageBox typename(ie) '为EMTPYFunction GetfocusHwnd()    Dim i,hWnd    hWnd = GetForegroundWindow()    For i = 0 To win.count - 1        If win(i).hWnd = hWnd Then            Set GetfocusHwnd = win(i)            MessageBox typename(GetfocusHwnd)'为IWEBBROWER2               Exit For             End If    NextEnd Function 
求解为什么第一个MessageBox typename(ie) '为EMTPY无效而函数内的有效,请高手赐教,如何解决,为什么不能封装成函数

[解决办法]
问题是啥?还要等着别人码字问问?
[解决办法]
这样呢

Dim Shell, win, hWnd
Set Shell = CreateObject("Shell.Application")
Set win = Shell.windows
Dim ie
set ie = win(GetfocusHwnd())
Delay 3000
MessageBox typename(ie) '为EMTPY

Function GetfocusHwnd()
Dim i,hWnd
hWnd = GetForegroundWindow()
For i = 0 To win.count - 1
If win(i).hWnd = hWnd Then
GetfocusHwnd = i
Exit For
End If
Next
End Function

[解决办法]
结贴啦
分不多

读书人网 >VB

热点推荐