Cara Membuat Barcode atau Mencetak Barcode dengan VB6 atau Visual Basic 6
yang terdiri dari barcode tunggal ataupun barcode kelompokDownload Visual Basic 6 atau VB6 dibawah ini :
Download Visual Basic 6.0 Enterprise Edition Service Pakc 6 (SP6)
Download Visual Basic 6.0 SP6
Download Visual Basic 6.0 Portable
Ada 2 mode pencetakan yang akan saya share disini :
1. Cetak barcode tunggal, sesuai namanya kita akan mencetak 1 kode barcode dengan posisi yang bisa kita atur sendiri.
2. Cetak barcode kelompok, mencetak beberapa kode barcode sekaligus
Oke langsung saja kita akan buat rancangan tampilannya seperti berikut :
Adapun kode pencetakannya adalah sebagai berikut :
Private Sub cmdCetak_Click()Dim batasKiri As SingleDim batasAtas As SingleDim posisi As IntegerIf MsgBox("Apakah proses pencetakan kode barcode ingin dilanjutkan ?", vbExclamation + vbYesNo,"Konfirmasi") = vbYes ThenScreen.MousePointer = vbHourglassDoEventsPrinter.PSet (0,0), vbWhitePrinter.ScaleMode = vbPixelsbatasKiri =0batasAtas =2.5posisi =0Do While posisi <30If Check1(posisi).Value = Checked ThenIf posisi >=0And posisi <=5ThenbatasKiri =0ElseIf posisi >=6And posisi <=11ThenbatasKiri =4ElseIf posisi >=12And posisi <=17ThenbatasKiri =8ElseIf posisi >=18And posisi <=23ThenbatasKiri =12ElsebatasKiri =16End IfSelect Case posisiCase0,6,12,18,24batasAtas =0.5Case1,7,13,19,25batasAtas =3.2Case2,8,14,20,26batasAtas =5.8Case3,9,15,21,27batasAtas =8.4Case4,10,16,22,28batasAtas =11.2Case5,11,17,23,29batasAtas =13.9End SelectTBarCode51.Text = txtKodeBarcode.TextTBarCode51.BackStyle = BKS_TransparentTBarCode51.BCDraw Printer.hDC, Printer.ScaleX(batasKiri, vbCentimeters), Printer.ScaleY(batasAtas, vbCentimeters), Printer.ScaleX(3, vbCentimeters), Printer.ScaleY(1.5, vbCentimeters)End Ifposisi = posisi +1LoopPrinter.EndDocScreen.MousePointer = vbDefaultEnd IfEnd Sub
dan terakhir kode untuk mencetak barcode kelompok :
Private Sub cmdCetak_Click()Dim x As LongDim y As LongDim Index As IntegerDim sgLeft1As SingleDim sgleft2As SingleDim sgTop As SingleDim fExit As BooleanIf MsgBox("Apakah proses pencetakan kode barcode ingin dilanjutkan ?", vbExclamation + vbYesNo,"Konfirmasi") = vbYes ThenScreen.MousePointer = vbHourglassDoEventsPrinter.PSet (0,0), vbWhitePrinter.ScaleMode = vbPixelssgTop = Printer.ScaleY(2.5, vbCentimeters)sgLeft1= Printer.ScaleX(1, vbCentimeters)While fExit = Falsex =1While fExit = False And x <=3y =1While fExit = False And y <=4'topmarginIf y >1ThensgTop = sgTop + Printer.ScaleY(3.5, vbCentimeters)ElsesgTop = Printer.ScaleY(2.5, vbCentimeters)End If'leftmarginIf x =1Thensgleft2= Printer.ScaleX(1, vbCentimeters)ElseIf x =2Thensgleft2= sgLeft1+ Printer.ScaleX(6.79, vbCentimeters)Elsesgleft2= sgLeft1+ Printer.ScaleX(6.64, vbCentimeters)End IfIf Not ((Index +1) > lstDaftarBarcode.ListCount) ThenTBarCode51.Text = lstDaftarBarcode.List(Index)TBarCode51.BackStyle = BKS_TransparentTBarCode51.BCDraw Printer.hDC, sgleft2, sgTop, Printer.ScaleX(4.4, vbCentimeters), Printer.ScaleY(1, vbCentimeters)End IfIf (Index +1) > lstDaftarBarcode.ListCount ThenfExit = TrueElseIndex = Index +1End Ify = y +1WendsgLeft1= sgleft2x = x +1WendIf Not fExit ThenPrinter.NewPagesgTop = Printer.ScaleY(2, vbCentimeters)sgLeft1= Printer.ScaleX(1.5, vbCentimeters)End IfWendPrinter.EndDocScreen.MousePointer = vbDefaultEnd IfEnd Sub
Download Sample Barcode
Thank's for reading the articelCara Membuat Barcode atau Mencetak Barcode dengan VB6 (Visual Basic 6) .If You want to copy paste your website please tag my link Cara Membuat Barcode atau Mencetak Barcode dengan VB6 (Visual Basic 6) Intro My Website.

0 comments:
Post a Comment