首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

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

2012-02-23 
VBSCRIPT简单又很奇怪的Function相关问题VBScript codeDim Shell, win, hWndSet Shell CreateObject(Sh

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 

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

热点排行