{"id":524,"date":"2012-11-23T14:35:49","date_gmt":"2012-11-23T14:35:49","guid":{"rendered":"http:\/\/www.bardecode.com\/en1\/?p=524"},"modified":"2013-03-05T11:42:25","modified_gmt":"2013-03-05T11:42:25","slug":"code-snippets-for-vbnet","status":"publish","type":"post","link":"https:\/\/www.bardecode.com\/en1\/code-snippets-for-vbnet\/","title":{"rendered":"Code snippets for VB.net"},"content":{"rendered":"<p>This arcticle shows some simple VB.net code snippets that reference the .net component or com object for the SDK in Visual Studio.<\/p>\n<p><strong>.NET Managed Class Library with Visual Studio 2003<\/strong><\/p>\n<p>&#8216;Add a reference to SoftekBarcodeLib.dll<\/p>\n<p>Dim barcode As SoftekBarcodeLib.BarcodeReader<br \/>\nbarcode = New SoftekBarcodeLib.BarcodeReader<\/p>\n<p>&#8216;Set properties<br \/>\nbarcode.ReadCode128 = True<\/p>\n<p>&#8216;Read barcodes<br \/>\nnBarCodes = barcode.ScanBarCode(Path)<\/p>\n<p>&#8216;Get results<br \/>\nFor i = 1 To nBarCodes<br \/>\nstrBarcode = barcode.GetBarString(i)<\/p>\n<p><strong>.NET Managed Class Library with Visual Studio 2005\/2008<\/strong><\/p>\n<p>&#8216;Add a reference to SoftekBarcodeLib2.dll<\/p>\n<p>Dim barcode As SoftekBarcodeLib2.BarcodeReader<br \/>\nbarcode = New SoftekBarcodeLib2.BarcodeReader<\/p>\n<p>&#8216;Set properties<br \/>\nbarcode.ReadCode128 = True<\/p>\n<p>&#8216;Read barcodes<br \/>\nnBarCodes = barcode.ScanBarCode(Path)<\/p>\n<p>&#8216;Get results<br \/>\nFor i = 1 To nBarCodes<br \/>\nstrBarcode = barcode.GetBarString(i)<\/p>\n<p><strong>Standard Windows DLL<\/strong><\/p>\n<p>Dim hBarcode As System.IntPtr<\/p>\n<p>hBarcode = mtCreateBarcodeInstance()<\/p>\n<p>&#8216;See the example project for the function definitions for the SoftekBarcode dll file.<\/p>\n<p>&#8216;Set properties<br \/>\nmtSetReadCode128(hBarcode, True)<\/p>\n<p>&#8216;Read barcodes<br \/>\nnBarCodes = mtScanBarCode(hBarcode, Path)<\/p>\n<p>&#8216;Get results<br \/>\nFor i = 1 to nBarCodes<br \/>\nstrBarcode =\u00a0System.Runtime.InteropServices.Marshal.PtrToStringAnsi(mtGetBarString(hBarcode, i)))<\/p>\n<p>mtDestroyBarcodeInstance(hBarcode)<\/p>\n<p><strong>COM Object<\/strong><\/p>\n<p>&#8216;Add a reference to SoftekATL.dll<br \/>\nDim oBarcode As SoftekATL.CBarcode<br \/>\noBarcode = New SoftekATL.CBarcode<\/p>\n<p>&#8216;Set properties<br \/>\noBarcode.ReadCode128 = True<\/p>\n<p>&#8216;Read barcodes<br \/>\noBarcode.ScanBarCode(Path.ToString)<br \/>\nnBarCodes = oBarcode.BarCodeCount<\/p>\n<p>&#8216;Get results<br \/>\nFor i = 1 to nBarCodes<br \/>\nstrBarcode = oBarcode.BarString(i)<\/p>\n<p><strong>Adding References to Visual Studio<\/strong><\/p>\n<p>To add a reference in Visual Studio, select &#8220;Add Reference&#8221; from the Project menu.<\/p>\n<p>To add a reference for the managed class library, browse for the SoftekBarcodeLib.dll file for VS 2003 and SoftekBarcodeLib2.dll for VS 2005\/2008 in your windows system folder.<\/p>\n<p>To add a reference for the COM object, click on the COM tab and select SofteATL 1.0 Type Library from the list.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This arcticle shows some simple VB.net code snippets that reference the .net component or com object for the SDK in Visual Studio. .NET Managed Class Library with Visual Studio 2003 &#8216;Add a reference to SoftekBarcodeLib.dll Dim barcode As SoftekBarcodeLib.BarcodeReader barcode = New SoftekBarcodeLib.BarcodeReader &#8216;Set properties barcode.ReadCode128 = True &#8216;Read barcodes nBarCodes = barcode.ScanBarCode(Path) &#8216;Get results<\/p>\n<p><a href=\"https:\/\/www.bardecode.com\/en1\/code-snippets-for-vbnet\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":316,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,31],"tags":[61,19,58,33,59,62,57,60],"class_list":["post-524","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-knowledge-base","category-software-development-kits","tag-net","tag-barcode","tag-code","tag-component","tag-snippet","tag-software","tag-visual-basic","tag-visual-studio"],"_links":{"self":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/524"}],"collection":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/comments?post=524"}],"version-history":[{"count":5,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/524\/revisions"}],"predecessor-version":[{"id":1676,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/524\/revisions\/1676"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media\/316"}],"wp:attachment":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media?parent=524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/categories?post=524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/tags?post=524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}