Dim cb As String = e.Form.Controls("ComboBox1").Value
Dim tb As String = e.Form.Controls("ComboBox2").Value
If cb = "生产号码"
Dim ii As Integer
Dim sz1 As String
Dim zf1 As String
For ii = 0 To tb.Length - 1
If Char.IsDigit(tb.Chars(ii)) Then
sz1 = sz1 + tb.Chars(ii)
Else
zf1 = zf1 + tb.Chars(ii)
End If
Next
Dim cmd As new SQLCommand
cmd.C
Dim dr As DataTable
cmd.CommandText = "Select 生产单号,条码起始号,订单总数量 from {新建订单} where 条码起始号 is not null order by [条码起始号]"
dr = cmd.ExecuteReader()
Dim hh As Integer = dr.DataRows.Count
For i As Integer = 0 To hh - 1
Dim qsh1 As String = dr.datarows(i)("条码起始号")
Dim zsl As Long = dr.datarows(i)("订单总数量")
Dim sz2 As String = ""
Dim zf3 As String = ""
For ii = 0 To qsh1.Length - 1
If Char.IsDigit(qsh1.Chars(ii)) Then
sz2 = sz2 + qsh1.Chars(ii)
Else
zf3 = zf3 + qsh1.Chars(ii)
End If
Next
If Clng(sz1) >= Clng(sz2) And Clng(sz1) <= (Clng(sz2) + zsl)
Dim scd As Long = dr.datarows(i)("生产单号")
DataTables("新建订单").LoadFilter = " 生产单号 = " & scd & " "
DataTables("新建订单").Load
Dim sch As Integer = Tables("新建订单.生产号码表").rows.Count
For iii As Integer = 0 To sch - 1
Dim jsh1 As String = Tables("新建订单.生产号码表").rows(iii)("生产号码_结束")
Dim sz3 As String = ""
For ii = 0 To jsh1.Length - 1
If Char.IsDigit(jsh1.Chars(ii)) Then
Sz3 = sz3 + jsh1.Chars(ii)
End If
Next
If Clng(sz1) <= Clng(sz3)
Tables("新建订单.生产号码表").Position = iii '定位到找到的行
(这里定位是对的,运行时可以看到已经标识到当前行,但下一刻又自动回到第一行,不知道为什么?即使把这段定位代码放到程序最后一行也是一样!)
Exit For
End If
Next
Exit For
End If
Next
End If