if filesys.fileExists("C:\barcode_up\ChSSU.txt") = true then
Dim gb As System.Text.Encoding = System.Text.Encoding.GetEncoding("GB2312")
Dim Muti As string = FileSys.ReadAllText("C:\barcode_up\ChSSU.txt",gb)
Dim Values() As String = Muti.Split(Chr(10))
For Index As Integer = 0 To Values.Length - 2
Dim s As String = Values(Index).Trim
If Not s.EndsWith("C") or s.length < 30 Then
Continue For
End If
Dim r As Row = Tables("转库数据上传_Table1").rows.AddNew()
Dim bytes() As byte = gb.GetBytes(s)
dim time1 as string = gb.GetString(bytes,71,12)
dim s1 as string = time1.SubString(0,4) & "-" & time1.SubString(4,2) & "-" & time1.SubString(6,2)
dim s2 as string = s1 & " " & time1.SubString(8,2) & ":" & time1.SubString(10,2) & ":00"
dim kbh as string = gb.GetString(bytes,0,29)
if kbh <> "" then
dim kbh1 as string = kbh.SubString(0,1)
dim kbh2 as string = kbh1.ToUpper()
kbh = kbh.TrimStart("S")
if kbh2 = "S" then
kbh = kbh.substring(0,6) & "-" & kbh.substring(6,kbh.length - 6)
end if
end if
r("捆包号") = kbh
r("条码号") = gb.GetString(bytes,0,29)
r("库位") = gb.GetString(bytes,30,40)
r("扫描时间") = s2
r("上传人") = Vars("用户")
r("上传时间") = format(date.now,"yyyy-MM-dd HH:mm:ss")
if r("捆包号") <> "" or r("库位") <> "" then
r("有效标记") = "有效" 'gb.GetString(bytes,166,1)
else
r("有效标记") = "无效" 'gb.GetString(bytes,166,1)
end if
Next
else
MessageBox.Show("转库扫描数据文件不存在,请检查!","提示")
end if
以上是我读取条形码产生的文本数据。每一行需要一个换行符或一个结束符。(条形码机器编程可达到的),参考下,看是否对你有帮助。