我对VBScript很新,我会在数组列表中显示示例数据以及我希望结果如何:
示例数据:
Variable 1 Variable 2
Feb-18 6ce3f076-ffa8-4902-a33a-019c6534a79f
Feb-18 6ce3f076-ffa8-4902-a33a-019c6534a79f
Feb-18 6ce3f076-ffa8-4902-a33a-019c6534a79f
Feb-18 6ce3f076-ffa8-4902-a33a-019c6534a79f
Feb-18 6ce3f076-ffa8-4902-a33a-019c6534a79f
Feb-18 97f8eb8e-877f-4e00-80e0-9d8de22f47fd
Feb-18 97f8eb8e-877f-4e00-80e0-9d8de22f47fd
Feb-18 Unassigned
Apr-18 Unassigned
May-18 Unassigned
Jun-18 Unassigned
Jul-18 Unassigned
Aug-18 Unassigned
Sep-18 Unassigned
Dec-18 Unassigned
Feb-18 Unassigned
我需要输出为:
new_Variable_1 new_Variable_2
6ce3f076-ffa8-4902-a33a-019c6534a79f 5
97f8eb8e-877f-4e00-80e0-9d8de22f47fd 2
Unassigned 9
我尝试了很多方法,但没有成功。
任何人都可以帮助我使用VBScript完成此任务。
任何指针都非常感谢。
答案 0 :(得分:0)
看一下下面的例子:
Option Explicit
Dim aVariable2, vItem, aResult1, aResult2
aVariable2 = Array("6ce3f076-ffa8-4902-a33a-019c6534a79f", "6ce3f076-ffa8-4902-a33a-019c6534a79f", "6ce3f076-ffa8-4902-a33a-019c6534a79f", "6ce3f076-ffa8-4902-a33a-019c6534a79f", "6ce3f076-ffa8-4902-a33a-019c6534a79f", "97f8eb8e-877f-4e00-80e0-9d8de22f47fd", "97f8eb8e-877f-4e00-80e0-9d8de22f47fd", "Unassigned", "Unassigned", "Unassigned", "Unassigned", "Unassigned", "Unassigned", "Unassigned", "Unassigned", "Unassigned")
With CreateObject("Scripting.Dictionary")
For Each vItem In aVariable2
.Item(vItem) = .Item(vItem) + 1
Next
aResult1 = .Keys()
aResult2 = .Items()
End With
MsgBox Join(aResult1, vbCrLf)
MsgBox Join(aResult2, vbCrLf)