我最近用FedEx扫描枪改变了扫描枪到黄蜂扫描枪。现在,当我扫描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 & "')"
答案 0 :(得分:0)
正确会这样做:
Code = Right(strIn, 12)
答案 1 :(得分:0)
这就是我解决这个问题的方法。
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 & "')"