BarCode Reader SDK使用教程:用VB6实现条码的生成和读取

Posted on 2015-11-02 12:25  Rforyou  阅读(626)  评论(0编辑  收藏  举报

如何用VB6生成和读取条码?今天给大家分享两段VB6代码,关于在BarCode Reader SDK条码的生成和读取。

生成条码:

Set <span data-scayt_word="bc" data-scaytid="8">bc</span> = <span data-scayt_word="CreateObject" data-scaytid="10">CreateObject</span>("Bytescout.BarCode.Barcode")

' set <span data-scayt_word="symbology" data-scaytid="11">symbology</span> to <span data-scayt_word="Code39" data-scaytid="13">Code39</span>
bc.Symbology = 1 ' 1 = <span data-scayt_word="Code39" data-scaytid="14">Code39</span> <span data-scayt_word="symbology" data-scaytid="12">symbology</span> type

' set barcode value to encode
bc.Value = "012345"

bc.SaveImage "Code39.png"

Set <span data-scayt_word="bc" data-scaytid="9">bc</span> = Nothing

  

读取条码:

Set <span data-scayt_word="bc" data-scaytid="17">bc</span> = <span data-scayt_word="CreateObject" data-scaytid="19">CreateObject</span>("Bytescout.BarCodeReader.Reader")

' limit to <span data-scayt_word="1D" data-scaytid="1">1D</span> barcodes search only (<span data-scayt_word="2d" data-scaytid="2">2d</span> are not included to speed up search)
bc.TypeToFind = 2066431 ' 2066431=SymbologyFilter.FindAll1D

bc.ReadFromFile "Code39.png"

For i = 0 To bc.FoundCount - 1
<span data-scayt_word="Msgbox" data-scaytid="3">Msgbox</span> "Found barcode on page #" & <span data-scayt_word="CStr" data-scaytid="4">CStr</span>(bc.GetFoundBarcodePage(i)) & " with type " & <span data-scayt_word="Cstr" data-scaytid="5">Cstr</span>(bc.GetFoundBarcodeType(i)) & " and value " & bc.GetFoundBarcodeValue(i)

Next

Set <span data-scayt_word="bc" data-scaytid="18">bc</span> = Nothing

  

本文译自BarCode