MS Access 提取条码的最后 12 位数字
MS Access Pulling last 12 digits of barcode
我最近将扫描枪从 FedEx 扫描枪换成了 Wasp 扫描枪。现在,当我扫描 FedEx 标签时,它会显示 24 个字符的跟踪信息,而我只需要最后 12 位数字。我还将扫描 UPS 标签,它们是字母数字的。有什么方法可以截断扫描到文本框中的全数字条码的最后 12 位数字吗?
我当前的代码让我去掉了前导零,但如果我能得到最后 12 位数字,我就不需要那段代码了。
当前代码:
Dim strIn As String
Dim i As Integer
Dim iLen As Integer
strIn = Me.txt_Track.Value
iLen = Len(strIn)
For i = 1 To iLen
For i = 1 To iLen
If InStr(strIn, "0") = 1 Then
strIn = Mid(strIn, 2)
End If
Next i
CurrentDb.Execute
"INSERT INTO TrackNum_Table(TrackingNum_TrackNum) " & _
"VALUES ('" & strIn & "')"
对会这样:
Code = Right(strIn, 12)
我就是这样解决的。
Dim strIn As String
Dim strOut As String
strIn = Me.txt_Track.Value
Numeric = IsNumeric(strIn)
If Numeric = True Then
strOut = Right(strIn, 12)
Else
strOut = strIn
End If
CurrentDb.Execute _
"INSERT INTO TrackNum_Table(TrackingNum_TrackNum) " & _
"VALUES ('" & strOut & "')"
我最近将扫描枪从 FedEx 扫描枪换成了 Wasp 扫描枪。现在,当我扫描 FedEx 标签时,它会显示 24 个字符的跟踪信息,而我只需要最后 12 位数字。我还将扫描 UPS 标签,它们是字母数字的。有什么方法可以截断扫描到文本框中的全数字条码的最后 12 位数字吗?
我当前的代码让我去掉了前导零,但如果我能得到最后 12 位数字,我就不需要那段代码了。
当前代码:
Dim strIn As String
Dim i As Integer
Dim iLen As Integer
strIn = Me.txt_Track.Value
iLen = Len(strIn)
For i = 1 To iLen
For i = 1 To iLen
If InStr(strIn, "0") = 1 Then
strIn = Mid(strIn, 2)
End If
Next i
CurrentDb.Execute
"INSERT INTO TrackNum_Table(TrackingNum_TrackNum) " & _
"VALUES ('" & strIn & "')"
对会这样:
Code = Right(strIn, 12)
我就是这样解决的。
Dim strIn As String
Dim strOut As String
strIn = Me.txt_Track.Value
Numeric = IsNumeric(strIn)
If Numeric = True Then
strOut = Right(strIn, 12)
Else
strOut = strIn
End If
CurrentDb.Execute _
"INSERT INTO TrackNum_Table(TrackingNum_TrackNum) " & _
"VALUES ('" & strOut & "')"