Skip to main content

Search

Search

Parsing a QR code

Comments

3 comments

  • Avatar
    Xabier Clemente
    Moderator

    Hi Bryan!

    We appreciate you reaching us via our Community Forums.

    Perhaps what you are trying to accomplish could be done with a Search and Replace function. There should be some tutorials online with examples.

    Also, we would recommend reaching our complimentary Professional Services Department or one of our BarTender Partners in case you need further and more dedicated help with VBS scripting.

    Cheers,

    0
  • Avatar
    Brian Cooler

    Ok, I figured it out with the help of some community forums searches. I placed this in the OnPostPrompt section of the Event Control Scripts:

    Dim patrn, patrnLen, strng, regEx, Match, Matches, i' Create variables
    Dim Delim1, Delim3, Delim4, Delim5, Delim6, Delim8, Val_1, Val_3, Val_4, Val_5, Val_6, Val_8
       Value = PARSETEST
       Value = Format.NamedSubStrings("PARSETEST").Value

       patrn = "<CRTA>" 'This is the delimiter (text the seperates components within the string) for the QR code
       patrnLen = Len(patrn)
       strng = Value 'PARSETEST 'This is the Name of the QR code on the label AND what is scanned in at print time.

       Set regEx = New RegExp   ' Create a regular expression.
       regEx.Pattern = patrn   ' Inputting the delimiter text we're looking for
       regEx.Global = True   ' True = pattern should match all occurrences in an entire search string
       regEx.IgnoreCase = False 

       Set Matches = regEx.Execute(strng)   ' Execute search which finds the locations for ALL occurrences of the delimiter.
       i=1 'setting counter to 1
       For Each Match in Matches   ' Iterate Matches collection.
          select case i 'iterrating through delimiters to parse data
             Case 1
                Delim1 = Match.FirstIndex 'delimiter location
                Val_1 = Mid(strng,1,Delim1) 'value of parsed information
                Format.NamedSubStrings("PARTNO").Value = Val_1 'sending parsed data to named Data Sources (PARTNO is a named text box)
             Case 3
                Delim3 = Match.FirstIndex 'I'm only parsing some of the data    
             Case 4
                Delim4 = Match.FirstIndex 'delimiter location
                Val_4 = Mid(strng,Delim3+patrnLen +1,Delim4-Delim3-patrnLen) 'value of parsed information            
                Format.NamedSubStrings("WHSE").Value = Val_4 
             Case 5
                Delim5 = Match.FirstIndex 'delimiter location
                Val_5 = Mid(strng,Delim4+patrnLen +1,Delim5-Delim4-patrnLen) 'value of parsed information            
                Format.NamedSubStrings("LOT").Value = Val_5 
             Case 6
                Delim6 = Match.FirstIndex 'delimiter location
                Val_6 = Mid(strng,Delim5+patrnLen +1,Delim6-Delim5-patrnLen) 'value of parsed information            
                Format.NamedSubStrings("PRJ").Value = Val_6          
             Case 8
                Delim8 = Match.FirstIndex 'delimiter location
                Val_8 = Right(strng, Len(strng)-Delim8-patrnLen) 'value of parsed information            
                Format.NamedSubStrings("UOM").Value = Val_8             
          end select
          i=i+1
       Next

    0
  • Avatar
    Xabier Clemente
    Moderator

    Awesome! Thank you for sharing this with us! :)

    0

Please sign in to leave a comment.