翻譯|使用教程|編輯:黃竹雯|2018-10-16 11:21:39.000|閱讀 370 次
概述:本系列教程會解答您在使用條形碼生成控件TBarCode SDK產品時遇到的絕大部分疑惑。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
TBarCode SDK是一款可以在任意應用程序和打印機下生成和打印所有條碼的條碼軟件組件。TBarCode SDK對于Microsoft® Office 用戶以及軟件開發者提供條碼打印。使用此款條碼軟件組件您可以以完美效果生成和打印所有用于工業和商業條碼符號。
無法將TBarCode直接添加到報表中,但您可以“動態”創建條形碼圖像并將其加載到圖片框中。按照以下說明查看如何將TBarCode嵌入到Crystal Reports 8中。
通過圖片框嵌入(VB6例子)
在一個表格(名為“Form1”)中嵌入一個TBarCode Control(名為“tbc”)和一個圖片框(名為“TmpPicture1”)。然后將下面的功能代碼添加到表單中。它“on the fly”創建條形碼圖像,并使用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事件)中調用條形碼生成器功能,并將新創建的條形碼圖像分配給報告中的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例子)
在一個表格(名為“Form1”)中嵌入一個TBarCode Control(名為“TBarCode”)并根據需要調整條形碼類型和所有其他設置。該條形碼對象將在報告運行期間用于“on the fly”創建條形碼。
在Report事件代碼(格式事件)中,在臨時文件夾中創建動態條形碼圖像,并將此圖像加載到報告中的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
如果您不想在表單上添加條形碼控件,則可以在內存中創建TBarCode實例并以編程方式應用設置。
如果未使用CreateObject指定完整的Prog-ID,則可能會收到此運行時錯誤。在項目設置中引用TBarCode Type Lib,并使用以下命令在VB中創建TBarCode對象(TBarCode OCX V9的例子):
Dim objTB As TBarCode9 Set objTB = CreateObject("TBarCode9.TBarCode9") objTB.AboutBox
可調整屬性 | TBarCode | 條形碼字體 |
模塊寬度 | 是* | 沒有 |
打印比率 | 可自由擴展 | 保持特殊的高/寬比 |
旋轉0°,90°,180°,270° | 是 | 不總是 |
*條形寬度的微調可以為您提供更好的條形碼質量結果
其中包含ActiveX Control文檔的啟動過程中發生的許可。
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
我們建議在項目屬性窗口中使用密碼保護您的VBA代碼。
福利時間:點擊此處>>>>>>獲得TBarCode SDK的完整應用示例。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn