我在命令窗口运行下面的代码结果就是正确的。
Dim str As String = "[{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""1"",""u8OrderNo"":""021607102"",""u8LineNo"":""13"",""productNo"":""CBSWI-SWI1630A"",""productType"":""LS6803"",""bdMaterialNo"":""CBSWI-SWI1630A"",""bdMaterialName"":""LS6803"",""productionQuantity"":""1"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":"""",""swVersion"":""""},{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""2"",""u8OrderNo"":""021607102"",""u8LineNo"":""9"",""productNo"":""CBSWI-JCA0772B"",""productType"":""LS68-24GE-SFP-V3"",""bdMaterialNo"":""CBSWI-JCA0772B"",""bdMaterialName"":""LS68-24GE-SFP-V3"",""productionQuantity"":""1"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":""1*1"",""swVersion"":""""},{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""3"",""u8OrderNo"":""021607102"",""u8LineNo"":""10"",""productNo"":""CBSWI-JCA0790B"",""productType"":""LS68-MSU-III-B"",""bdMaterialNo"":""CBSWI-JCA0790B"",""bdMaterialName"":""LS68-MSU-III-B"",""productionQuantity"":""1"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":""1*1"",""swVersion"":""""},{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""4"",""u8OrderNo"":""021607102"",""u8LineNo"":""11"",""productNo"":""CBPOW-POW0112A"",""productType"":""英文中性化LS68-PWR-AC-600"",""bdMaterialNo"":""CBPOW-POW0112A"",""bdMaterialName"":""英文中性化LS68-PWR-AC-600"",""productionQuantity"":""2"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":""1*2"",""swVersion"":""""},{""workOrderNo"":""SC20160810103"",""workOrderLineNo"":""5"",""u8OrderNo"":""021607102"",""u8LineNo"":""12"",""productNo"":""CBSWI-JCA0774B"",""productType"":""LS68-12GE-TX/SFP-V3"",""bdMaterialNo"":""CBSWI-JCA0774B"",""bdMaterialName"":""LS68-12GE-TX/SFP-V3"",""productionQuantity"":""1"",""typeDscr"":"""",""depName"":""制造中心-装配部-高端"",""startDate"":""2016-08-17 00:00:00.0"",""endDate"":""2016-08-22 00:00:00.0"",""activeOSNo"":"""",""remark"":""1*1"",""swVersion"":""""}]"
msgbox(str)
Dim data As object
Dim JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
Dim ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
.Language = "Javascript"
.Timeout = -1
.AddCode(JscriptCode)
data = .Run("toObject", str)
End With
For Each info As object In data
Dim rr As Row = Tables("计划表").AddNew
rr("生产订单号码") = Info.workOrderNo
rr("工单行号") = Info.workOrderLineNo
rr("工单") = rr("生产订单号码") & "-" & rr("工单行号")
rr("订单号") = Info.u8OrderNo
rr("订单行号") = Info.u8LineNo
rr("客户物料编码") = Info.productNo
rr("客户物料名称") = Info.productType
rr("博达物料编码") = Info.bdMaterialNo
rr("博达物料名称") = Info.bdMaterialName
rr("生产订单数量") = Info.productionQuantity
rr("类别说明") = Info.typeDscr
rr("部门名称") = Info.depName
rr("开工日期") = Info.startDate
rr("完工日期") = Info.endDate
rr("两化表编号") = Info.activeOSNo
rr("备注") = Info.remark
rr("软件版本") = Info.swVersion
rr("销售订单_行号") = rr("订单号") & "-" & rr("订单行号")
rr.save
Next
如果在keydown运行,
就提示错误所在事件:窗口,生产入库,TextBox3,KeyDown
详细错误信息:
缺少 ';
Dim dl As new ClassLibrary1.Class1()
Dim Multi As String =dl.getSchInfoByWorkInfo_1(str1,str2)
If Multi.Length = 0 Then
MessageBox.show("工单号行号:" & str & "没有导入订单系统,请告知计划人员","异常",MessageBoxButtons.OK,MessageBoxIcon.Error)
Else
msgbox (Multi)
Dim data As object
Dim JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
Dim ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
.Language = "Javascript"
.Timeout = -1
.AddCode(JscriptCode)
data = .Run("toObject", Multi)
End With
For Each info As object In data
Dim rr As Row = Tables("计划表").AddNew
rr("生产订单号码") = Info.workOrderNo
rr("工单行号") = Info.workOrderLineNo
rr("工单") = rr("生产订单号码") & "-" & rr("工单行号")
rr("订单号") = Info.u8OrderNo
rr("订单行号") = Info.u8LineNo
rr("客户物料编码") = Info.productNo
rr("客户物料名称") = Info.productType
rr("博达物料编码") = Info.bdMaterialNo
rr("博达物料名称") = Info.bdMaterialName
rr("生产订单数量") = Info.productionQuantity
rr("类别说明") = Info.typeDscr
rr("部门名称") = Info.depName
rr("开工日期") = Info.startDate
rr("完工日期") = Info.endDate
rr("两化表编号") = Info.activeOSNo
rr("备注") = Info.remark
rr("软件版本") = Info.swVersion
rr("销售订单_行号") = rr("订单号") & "-" & rr("订单行号")
rr.save
Next
End If
发现2个msgbox(str)和msgbox(Multi),结果不一样。一个去掉了多余的引号,一个仍然是返回的原值引号仍然保留
msgbox(str)
此主题相关图片如下:str.png
此主题相关图片如下:mutl.png
这是怎么回事呢?怎么改呢?ths
[此贴子已经被作者于2016/12/30 14:03:23编辑过]