With e.Form.Controls("textbox1")
Dim ctn1() As String = DataTables("出入库").SQLGetComboListString("物料编号", "[出入年月] = '" & .Value & "' and [来源] = '" & "自做" & "'").Split("|")
'msgbox("ctn1.length=" & ctn1.length) '数据正确
For s1 As Integer = 0 To ctn1.length - 1
msgbox("s1=" & s1) '这句会显示 s1 = 0, 然后出现“索引超出了数组界限”的提示
Dim ctn2() As String = DataTables("出入库").SQLGetComboListString("出入原因", "[出入年月] = '" & .Value & "' and [来源] = '" & "自做" & "' and [物料编号] = '" & ctn1(s1 - 1) & "'").Split("|")
msgbox("ctn2.length=" & ctn2.length) 这句就不出来了。
For s2 As Integer = 0 To ctn2.length - 1
msgbox("s2=" & s2)
Dim ctn3() As String = DataTables("出入库").SQLGetComboListString("不含税单价", "[出入年月] = '" & .Value & "' and [来源] = '" & "自做" & "' and [物料编号] = '" & ctn1(s1 - 1) & "' and [出入原因] = '" & ctn2(s2 - 1) & "'").Split("|")
For s3 As Integer = 0 To ctn3.length - 1
msgbox("s3=" & s3)
Dim qty1 As Single = Tables("出入库").Compute("sum(入库数量)", "出入年月 = '" & .Value & "' and 来源 = '" & "自做" & "' and 物料编号 = '" & ctn1(s1 - 1) & "' and 出入原因 = '" & ctn2(s2 - 1) & "' and 不含税单价 = '" & ctn3(s3 - 1) & "' ")
Dim qty2 As Single = Tables("出入库").Compute("sum(出库数量)", "出入年月 = '" & .Value & "' and 来源 = '" & "自做" & "' and 物料编号 = '" & ctn1(s1 - 1) & "' and 出入原因 = '" & ctn2(s2 - 1) & "' and 不含税单价 = '" & ctn3(s3 - 1) & "' ")
Dim dr1 As DataRow = DataTables("库存明细").Find("出入年月 = '" & .Value & "' and 物料编号 = '" & ctn1(s1 - 1) & "' and 出入原因 = '" & ctn2(s2 - 1) & "' and 不含税单价 = '" & ctn3(s3 - 1) & "'")
If dr1 IsNot Nothing Then
Else
Dim dr2 As DataRow = DataTables("库存明细").AddNew()
dr2("出入年月") = .Value
dr2("物料编号") = ctn1(s1 - 1)
dr2("出入原因") = ctn2(s2 - 1)
dr2("入库数量") = qty1
End If
Next
Next
Next
end with
老师好。请看上面代码里面红色部分我的说明。我想问的问题是,难道是蓝色那句有问题吗?如果是,要怎样修改?谢谢。