其中 arrList 是上述格式的 GetSubnetLocations 函数返回的列表(按字母顺序排列)
Dim arrMenu : ReDim arrMenu(-1)
Dim arrLocs : ReDim arrLocs(UBound(arrList),1)
i = 0
For Each x In arrList
'Also building option list here
intCount = Len(x) - Len(Replace(x,"/",""))
arrLocs(i,0) = x
arrLocs(i,1) = intCount
i = i + 1
Next
Result.InnerHTML = ""
ReDim Preserve arrMenu(UBound(arrMenu)+1)
arrMenu(UBound(arrMenu)) = "<ul id=""menu"">"
For x = 1 To UBound(arrLocs,1) Step 1
ReDim Preserve arrMenu(UBound(arrMenu)+1)
arrMenu(UBound(arrMenu)) = "<li><a>" & " " & arrLocs(x,0) & "</a></li>"
Next
For j = 1 To UBound(arrMenu)
If arrLocs(j,1) > arrLocs(j-1,1) Then
arrMenu(j-1) = Replace(arrMenu(j-1),"</li>","<ul style=""display:none"">")
End If
If arrLocs(j,1) < arrLocs(j-1,1) Then
For x = 1 To arrLocs(j-1,1) - arrLocs(j,1)
arrMenu(j-1) = arrMenu(j-1) & "</li>"
Next
End If
Next
ReDim Preserve arrMenu(UBound(arrMenu)+1)
arrMenu(UBound(arrMenu)) = "</ul>"
strMenu = ""
For Each n In arrMenu
strMenu = strMenu & n
Next
Result.InnerHTML = strMenu