求助VBA转为VFP
Function get_trace_json(mystring As String) As Integer
Dim objJSx, objJSy As Object
Set objJSx = CreateObject("ScriptControl")
objJSx.Language = "JavaScript"
jscode = "function json(s,i) { return eval('(' + s + ').traces[' + i + ']'); }"
objJSx.AddCode jscode
For n = 1 To 80
If objJSx.Run("json", mystring, n - 1) = "" Then Exit For
Set objJSy = objJSx.Run("json", mystring, n - 1)
stime(n) = objJSy.acceptTime
saddr(n) = objJSy.acceptAddress
state(n) = objJSy.remark
Debug.Print n & ":" & objJSy.acceptTime & objJSy.acceptAddress & objJSy.remark
Next n
If Left(state(n - 1), 2) = "妥投" Or Left(state(n - 1), 5) = "投递并签收" Then tt = "OK"
get_trace_json = n – 1
End Function
Function get_trace_json1(mystring As String) As Integer
Dim objJSx, objJSy As Object
Set objJSx = CreateObject("ScriptControl")
objJSx.Language = "JavaScript"
jscode = "var json=" & mystring & ";"
objJSx.AddCode (jscode)
For n = 1 To 80
jscode = "var json_tr=json.traces[" & n - 1 & "];"
objJSx.AddCode (jscode)
If objJSx.CodeObject.json_tr = "" Then Exit For
Set objJSy = objJSx.CodeObject.json_tr
stime(n) = CallByName(objJSy, "acceptTime", VbGet)
saddr(n) = CallByName(objJSy, "acceptAddress", VbGet)
state(n) = CallByName(objJSy, "remark", VbGet)
Debug.Print n & ":" & objJSy.acceptTime & objJSy.acceptAddress & objJSy.remark
Next n
If Left(state(n - 1), 2) = "妥投" Or Left(state(n - 1), 5) = "投递并签收" Then tt = "OK"
get_trace_json1 = n - 1
End Function