0

此代码是使用 A 软件 Kofax 并使用 WinWrap。我使用条形码定位器来提取四个不同的条形码。我试图将条形码分配给字段名称。基于他们的模式。

    Private Sub BarCode_script_LocateAlternatives(ByVal pXDoc As CASCADELib.CscXDocument, ByVal 
    pLocator As CASCADELib.CscXDocField)
     Dim Barcodes As CscXDocFieldAlternatives
     Dim PatternCoda As String
     Dim PatternBatch As String
     Dim PatternXXL As String
     Dim SPB As String
     Dim matches As MatchCollection
     Dim regex As RegExp

     PatternCoda = ("[A-Z]{4}[-]\d{6}")
     PatternBatch = "\d{4}[-]\d{5}[-]\d{2}"
     PatternXXL = "[A-Z]{3}[-][A-Z]{2}\d{5}"

     Set Barcodes = pXDoc.Locators.ItemByName("BarCode_finder").Alternatives
     If Barcodes.Count=0 Then Exit Sub

     Set regex = New RegExp
     regex.IgnoreCase = True
     regex.Global = True
     regex.Pattern = PatternCoda
     Set matches = regex.Execute(Barcodes(0).Text)
     If matches = regex.Pattern Then
        SPB = matches
     End If

     pLocator.Alternatives.Create
     pLocator.Alternatives(0).SubFields.Create("BatchName")
     pLocator.Alternatives(0).SubFields.Create("ClientName")
     pLocator.Alternatives(0).SubFields.Create("XXLName")

     pLocator.Alternatives.ItemByIndex(0).Confidence = Barcodes(0).Confidence

      With pLocator.Alternatives(0).SubFields
        .ItemByName("ClientName").Text = SPB
        .ItemByName("ClientName").Confidence=Barcodes(0).Confidence
     End With

     End Sub
4

0 回答 0