有一种二维码格式是,只有最后一行才有回车,不是每行都有回车。扫描后发现没有增加10行数据,只增加1行数据。遇到这种格式的怎么解决?
此主题相关图片如下:二维码.png
DataColChanging:
If e.DataCol.Name = "SN" Then
Dim str As String = e.NewValue.Replace(chr(10), "").Replace(chr(13), "")
Dim idx1 As Integer = str.IndexOf("MAC:")
Dim idx2 As Integer = str.IndexOf("H/W:")
Dim length As Integer
If str.Contains("SN:") Then
length = IIF(idx1 <> -1,idx1-3,IIF(idx2 <> -1,idx2-4,str.Length - 3))
e.NewValue = str.SubString(3, length)
Else
e.NewValue =str
End If
If str.Contains("MAC:") Then
If idx2 = -1 Then
e.DataRow("MAC") = str.SubString(idx1+4)
Else
e.DataRow("MAC") = str.SubString(idx1+4, idx2-idx1-4)
End If
End If
If str.Contains("H/W:") Then
e.DataRow("HW") = str.substring(idx2+4)
End If
End If
KeyDownEdit
If e.keyCode = Keys.Enter AndAlso e.Table.Cols(e.Table.colSel).Name = "SN" Then
e.cancel = True
Dim r As Row = e.Table.addnew
e.Table.Select(r.Index, 0)
e.Table.StartEditing
End If