【问题标题】:MS Access Pulling last 12 digits of barcodeMS Access 提取条形码的最后 12 位数字
【发布时间】:2018-03-10 08:23:12
【问题描述】:

我最近将扫描枪从 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 & "')"

【问题讨论】:

  • 最后 12 个位置是否总是数字,还是可以包含字母?
  • 假设,我们收到的所有 UPS 标签都是字母数字,我们希望保留所有这些标签。现在让我们假设扫描的所有数字条形码都是 FedEx,让我们截断这些并获取最后 12 位数字。

标签: ms-access ms-access-2013 ms-access-2016


【解决方案1】:

会这样做:

Code = Right(strIn, 12)

【讨论】:

  • 我怎样才能只在只有数字条形码的情况下使用它,因为通常联邦快递只发送数字。 UPS 通常会发送字母数字代码。
  • 你发现了,我看得出来。
【解决方案2】:

这就是我解决这个问题的方法。

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 & "')"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    相关资源
    最近更新 更多