做了以下测试
Str = Ojs.Eval("[""" & Join(Dict.Keys, """, """) & """].sort()")
Debug.Print Str
Str = "[""" & Join(Dict.Keys, """, """) & """].sort()"
Debug.Print Str
Str = Ojs.Eval(Str)
Debug.Print Str
Stop
结果如下
3,6,7,8,你,我,欣慰
["我", "6", "8", "你", "7", "欣慰", "3"].sort()
3,6,7,8,你,我,欣慰
按照思路又从新做了一边测试代码。
- Sub del()
- Dim Dict As Dictionary, Ojs As ScriptControl
- Dim Arr, ii, jj, Str
- Set Dict = New Dictionary
- Set Ojs = New ScriptControl
- Arr = [{"我",6,8,6,"你",7,"欣慰",8,3}]
- For ii = 1 To UBound(Arr)
- Dict(Arr(ii)) = ""
- Next ii
- Ojs.Language = "JScript"
- Arr1 = Split(Ojs.Eval("[""" & Join(Dict.Keys, """, """) & """].sort()"), ",")
- Str = Ojs.Eval("[""" & Join(Dict.Keys, """, """) & """].sort()")
- Debug.Print Str
- Str = "[""" & Join(Dict.Keys, """, """) & """].sort()"
- Debug.Print Str
- Str = Ojs.Eval(Str)
- Debug.Print Str
- Stop
- End Sub
复制代码
|