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
可是还有某些二维码内容没有SN:,MAC:,H/W: 中间就是一个空格作为分隔符。 如附件。怎么把这种格式也兼容进来?
此主题相关图片如下:2.png
