翻譯|使用教程|編輯:黃竹雯|2018-10-16 11:21:39.000|閱讀 370 次
概述:本系列教程會解答您在使用條形碼生成控件TBarCode SDK產(chǎn)品時(shí)遇到的絕大部分疑惑。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
TBarCode SDK是一款可以在任意應(yīng)用程序和打印機(jī)下生成和打印所有條碼的條碼軟件組件。TBarCode SDK對于Microsoft® Office 用戶以及軟件開發(fā)者提供條碼打印。使用此款條碼軟件組件您可以以完美效果生成和打印所有用于工業(yè)和商業(yè)條碼符號。
無法將TBarCode直接添加到報(bào)表中,但您可以“動態(tài)”創(chuàng)建條形碼圖像并將其加載到圖片框中。按照以下說明查看如何將TBarCode嵌入到Crystal Reports 8中。
通過圖片框嵌入(VB6例子)
在一個(gè)表格(名為“Form1”)中嵌入一個(gè)TBarCode Control(名為“tbc”)和一個(gè)圖片框(名為“TmpPicture1”)。然后將下面的功能代碼添加到表單中。它“on the fly”創(chuàng)建條形碼圖像,并使用PictureBox作為繪圖表面。
Public Function BarcodeGenerate(Id As String, Width As Long, Height As Long) As PictureBox Dim nSizing, cm tbc.Text = Id cm = tbc.CountModules TmpPicture1.Cls TmpPicture1.ScaleMode = vbPixels Form1.ScaleMode = vbPixels Width = ScaleX(Width, vbTwips, vbPixels) Height = ScaleY(Height, vbTwips, vbPixels) nSizing = Int(Width / cm) If nSizing < 1 Then nSizing = 1 TmpPicture1.Width = cm * nSizing TmpPicture1.Height = Height DoEvents tbc.BCDraw TmpPicture1.hDC, 0, 0, TmpPicture1.Width, TmpPicture1.Height Set BarcodeGenerate = TmpPicture1 End Function
在Report事件代碼(Format事件)中調(diào)用條形碼生成器功能,并將新創(chuàng)建的條形碼圖像分配給報(bào)告中的Picture Box(圖片框)(名為Picture1)。
Private Sub Section3_Format(ByVal pFormattingInfo As Object) 'create the bar code for each record set Dim data As String data = Field1.Value Set Me.Picture1.FormattedPicture = Form1.BarcodeGenerate(data, Me.Picture1.Width, Me.Picture1.Height).Image End Sub
通過位圖文件嵌入(VB6例子)
在一個(gè)表格(名為“Form1”)中嵌入一個(gè)TBarCode Control(名為“TBarCode”)并根據(jù)需要調(diào)整條形碼類型和所有其他設(shè)置。該條形碼對象將在報(bào)告運(yùn)行期間用于“on the fly”創(chuàng)建條形碼。
在Report事件代碼(格式事件)中,在臨時(shí)文件夾中創(chuàng)建動態(tài)條形碼圖像,并將此圖像加載到報(bào)告中的Picture Box(名為pictBarCode)。
Private Sub Section3_Format(ByVal pFormattingInfo As Object) ' Simulate data binding ' by saving the bar code as bitmap with data from fldArticleID ' then reload it to a picture control On Error Resume Next Dim nWidth Dim path Dim fso ' here we use hard coded temp path (must exist!) path = "c:\temp\CR8_" & Me.fldArticleID.Value & ".bmp" ' reference the TBarCode Control in the Form1 Form1.TBarCode.Text = Me.fldArticleID.Value Form1.TBarCode.PrintDataText = False nWidth = Form1.TBarCode.CountModules * 3 'adapt width to number of graphical modules Form1.TBarCode.SaveImage path, eIMBmp, nWidth, 100, 96, 96 Me.pictBarcode.SetOleLocation (path) End Sub
如果您不想在表單上添加條形碼控件,則可以在內(nèi)存中創(chuàng)建TBarCode實(shí)例并以編程方式應(yīng)用設(shè)置。
如果未使用CreateObject指定完整的Prog-ID,則可能會收到此運(yùn)行時(shí)錯(cuò)誤。在項(xiàng)目設(shè)置中引用TBarCode Type Lib,并使用以下命令在VB中創(chuàng)建TBarCode對象(TBarCode OCX V9的例子):
Dim objTB As TBarCode9 Set objTB = CreateObject("TBarCode9.TBarCode9") objTB.AboutBox
可調(diào)整屬性 | TBarCode | 條形碼字體 |
模塊寬度 | 是* | 沒有 |
打印比率 | 可自由擴(kuò)展 | 保持特殊的高/寬比 |
旋轉(zhuǎn)0°,90°,180°,270° | 是 | 不總是 |
*條形寬度的微調(diào)可以為您提供更好的條形碼質(zhì)量結(jié)果
其中包含ActiveX Control文檔的啟動過程中發(fā)生的許可。
Private Sub Workbook_Open() Dim tbc As TBarCode11 Set tbc = CreateObject ("TBarCode11.TBarCode11") tbc.LicenseMe "Mem:Licensee", eLicKindDeveloper, 1, "Key", TBarCode11Lib.eLicProd1D Set tbc = Nothing End Sub
我們建議在項(xiàng)目屬性窗口中使用密碼保護(hù)您的VBA代碼。
福利時(shí)間:點(diǎn)擊此處>>>>>>獲得TBarCode SDK的完整應(yīng)用示例。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn