各位专家好!
写了个函数,但是调来调去都说语法错误? 请各位帮忙看看是怎么回事?
Dim bomid As String = args(0) '物料清单编码
Dim part As String = args(1) '主料物料编号
Dim diffqty As Double = args(2) '主物料编号不足数
Dim poqty As Double '在途数量
Dim level As Integer '优先级
Dim drs As List(of DataRow) = DataTables("物料代用明细").Select(" 物料清单编码 = '" & bomid & "' And 原物料编号 = '" & part & "'")
If drs IsNot Nothing Then '如果有代用料的话
For level = 0 To drs.Count
Dim dr As DataRow = DataTables("物料代用明细").Find("物料清单编码 = '" & bomid & "' And 原物料编号 = '" & part & "' And 优先级 = '" & level & "'")
'If dr IsNot Nothing Then '如果代用料找到的话,优先级为0开始查找
Dim Total_stock As Double = Functions.Execute("GetTotalStock",dr("代用物料编号")) '先查找其总库存
If Total_stock >= (-diffqty) Then '如果代用料库存大于或等于不足数时,看是否存在需求表,存在则提取不足数,看是不是能够满足,能则更新,不能则下一个,不存在则写入需求表
Dim dr1 As DataRow = DataTables("物料需求表").Find("物料编号 = '" & dr("代用物料编号") & "'")
If dr1 IsNot Nothing Then '是否存在在物料需求表,存在则提取不足数,不存在则新增一个
Dim Sub_qty As Double = dr1("不足数量")
If Sub_qty >= (-diffqty) Then '存在在物料需求表里的代用料的不足数大于或等于主料不足数,则选其代用.否则找下一个.
dr1("需求数量") = dr1("需求数量") - diffqty
dr1("不足数量") = dr1("不足数量") - diffqty
dr1("备注")=dr1("备注") & "/" & "代用" & part & ":" &(-diffqty)
Exit For
Else
level = level + 1 '选择下一个优先级的代用料
End If
Else '新增一条记录在物料需求表中
poqty =0
For Each dr3 As DataRow In DataTables("仓库主文件").DataRows 'b
Dim dr4 As DataRow = DataTables("库存清单主文件").Find("物料编号 = '" & dr("代用物料编号") & "'And 仓库编码 = '" & dr3("仓库编码") & "'")
If dr4 IsNot Nothing Then '提取库存的在途数量和总库存量
poqty = poqty + dr3("在途数量") '总在途数量
End If
Next 'b
Dim dr2 As DataRow = DataTables("物料需求表").AddNew
dr2("物料编号") = dr("代用物料编号")
dr2("描述") = dr("物料描述")
dr2("单位") = dr("单位")
dr2("需求数量") = (-diffqty)
dr2("在途数量") = poqty
dr2("不足数量") = Total_stock + poqty - dr2("需求数量")
dr2("备注") = "代用" & part & ":" & dr2("需求数量")
Functions.Execute("Write_Stock_ToMrp",dr("代用物料编号"),dr2)
Exit For
End If
End If
'End If .
Next
End If
Return Nothing
把高亮处代码取消注释后出现错误。
此主题相关图片如下:编译错误.jpg