1
我把一些舊的VBScript爲Javascript有兩條線,我不知道如何正確地轉換。原來這裏是VBS:轉換VBS到JS:對於每個...在
function getCount()
on error resume next
dim allitems, strItemID, icnt
icnt = 0
set allitems = dsoITEMS.selectNodes("//item")
for each node in allitems
strItemID = node.selectsinglenode("item_id").firstchild.nodevalue
if err then
exit for
end if
if strItemID <> "" then
icnt = icnt + 1
end if
next
set nodes = nothing
getCount = icnt
end function
這裏是JS我到目前爲止:
function getCount(){
on error resume next;
var allitems, strItemID, icnt;
icnt = 0;
allitems = dsoITEMS.selectNodes("//item");
for each node in allitems;
strItemID = node.selectsinglenode("item_id").firstchild.nodevalue;
if(err){
exit for;
}
if(strItemID != ""){
icnt = icnt + 1;
}
next;
nodes = null;
getCount = icnt ;
}
我無法弄清楚如何轉換線「上的錯誤繼續下一步」和「在allitems每個節點」
'try {janky code here} catch(y){console.error(y); }' – dandavis
任何想法在allitems線的每個節點做一下呢? – dyr808