重新发布工作代码

(我试图从ActiveX组件中获取数组,但是没有运气。运行脚本时,我得到的是空的消息框,但我知道数组在那里:)

var objMain, objAdapt, lgCount, stMsg = "";

objMain = new ActiveXObject("nnetcom.oMain");

objMain.UnlockComponent("xxx-xxxxx-xxxxx-xx");

objAdapt = new ActiveXObject("nnetcom.oNetworkAdapter");

objAdapt.GetNetworkAdapters(); // Collects Network Adapters

vrAdapters = objAdapt.cName; // cName holds collected Network Adapter names

var vrAdaptVB = new VBArray(vrAdapters);

var vrAdaptJS = vrAdaptVB.toArray();

for (lgCount in vrAdaptJS) {
  stMsg = stMsg + vrAdaptJS[lgCount] + '\r\n';
}

WScript.Echo(stMsg);

objAdapt = null
objMain = null

最佳答案

var vrAdaptVB = new VBArray(vrAdapters);

var vrAdaptJS = vrAdaptVB.toArray();

stMsg = "";

for (lgCount = 0; lgCount < vrAdaptJS.length; ++lgCount) {
 stMsg = stMsg + vrAdaptJS[lgCount] + '\r\n';
}

关于javascript - JScript数组问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10268556/

10-09 17:32