方法一:sql = "select sum(a.数量) from (select distinct 条码号,数量 from [myTable]) a"
方法二:
Dim dic As New Dictionary(Of String, Integer) '声明字典
Dim son As KeyValuePair(Of String, Integer)
Dim k As Integer = 0
Dim dt As New DataTable '数据表
For Each drow As DataRow In dt.Rows
If Not dic.ContainsKey(drow("条码号")) Then
dic(drow("条码号")) = drow("数量")
End If
Next
For Each son In dic
k += son.Value
Next
MsgBox(k.ToString)