我无法尝试从图片框中打印生成的条形码图像。当我点击打印按钮时,我会打印到窗口,但打印时只会出现一张白纸。
代码在
之下Imports System.Drawing.Printing
Public Class Barcode_Generator
'CENTER FORM TO SCREEN
Dim WithEvents printdoc As New Printing.PrintDocument()
Dim pd_printdialog As New PrintDialog
Private Property PrintDialog1 As PrintDialog
Private Sub Barcode128_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CenterToScreen()
End Sub
'GENERATE BARCODE STRING
Private Function Code128B(foo As String) As String
Dim C(107) As String
Dim B(107) As String
Dim S(107) As String
Dim w(255) As String
Dim l As Integer = 0
Dim t As String = ""
Dim n, i As Integer
Dim check As Long = 0
Code128B = ""
B(0) = " " : C(0) = "00" : S(0) = "bb w bb ww bb ww"
B(1) = "!" : C(1) = "01" : S(1) = "bb ww bb w bb ww"
B(2) = Chr(34) : C(2) = "02" : S(2) = "bb ww bb ww bb w"
B(3) = "#" : C(3) = "03" : S(3) = "b ww b ww bb www"
B(4) = "$" : C(4) = "04" : S(4) = "b ww b www bb ww"
B(5) = "%" : C(5) = "05" : S(5) = "b www b ww bb ww"
B(6) = "&" : C(6) = "06" : S(6) = "b ww bb ww b www"
B(7) = "'" : C(7) = "07" : S(7) = "b ww bb www b ww"
B(8) = "(" : C(8) = "08" : S(8) = "b www bb ww b ww"
B(9) = ")" : C(9) = "09" : S(9) = "bb ww b ww b www"
B(10) = "*" : C(10) = "10" : S(10) = "bb ww b www b ww"
B(11) = "+" : C(11) = "11" : S(11) = "bb www b ww b ww"
B(12) = "," : C(12) = "12" : S(12) = "b w bb ww bbb ww"
B(13) = "-" : C(13) = "13" : S(13) = "b ww bb w bbb ww"
B(14) = "." : C(14) = "14" : S(14) = "b ww bb ww bbb w"
B(15) = "/" : C(15) = "15" : S(15) = "b w bbb ww bb ww"
B(16) = "0" : C(16) = "16" : S(16) = "b ww bbb w bb ww"
B(17) = "1" : C(17) = "17" : S(17) = "b ww bbb ww bb w"
B(18) = "2" : C(18) = "18" : S(18) = "bb ww bbb ww b w"
B(19) = "3" : C(19) = "19" : S(19) = "bb ww b w bbb ww"
B(20) = "4" : C(20) = "20" : S(20) = "bb ww b ww bbb w"
B(21) = "5" : C(21) = "21" : S(21) = "bb w bbb ww b ww"
B(22) = "6" : C(22) = "22" : S(22) = "bb ww bbb w b ww"
B(23) = "7" : C(23) = "23" : S(23) = "bbb w bb w bbb w"
B(24) = "8" : C(24) = "24" : S(24) = "bbb w b ww bb ww"
B(25) = "9" : C(25) = "25" : S(25) = "bbb ww b w bb ww"
B(26) = ":" : C(26) = "26" : S(26) = "bbb ww b ww bb w"
B(27) = ";" : C(27) = "27" : S(27) = "bbb w bb ww b ww"
B(28) = "<" : C(28) = "28" : S(28) = "bbb ww bb w b ww"
B(29) = "=" : C(29) = "29" : S(29) = "bbb ww bb ww b w"
B(30) = ">" : C(30) = "30" : S(30) = "bb w bb w bb www"
B(31) = "?" : C(31) = "31" : S(31) = "bb w bb www bb w"
B(32) = "@" : C(32) = "32" : S(32) = "bb www bb w bb w"
B(33) = "A" : C(33) = "33" : S(33) = "b w b www bb www"
B(34) = "B" : C(34) = "34" : S(34) = "b www b w bb www"
B(35) = "C" : C(35) = "35" : S(35) = "b www b www bb w"
B(36) = "D" : C(36) = "36" : S(36) = "b w bb www b www"
B(37) = "E" : C(37) = "37" : S(37) = "b www bb w b www"
B(38) = "F" : C(38) = "38" : S(38) = "b www bb www b w"
B(39) = "G" : C(39) = "39" : S(39) = "bb w b www b www"
B(40) = "H" : C(40) = "40" : S(40) = "bb www b w b www"
B(41) = "I" : C(41) = "41" : S(41) = "bb www b www b w"
B(42) = "J" : C(42) = "42" : S(42) = "b w bb w bbb www"
B(43) = "K" : C(43) = "43" : S(43) = "b w bb www bbb w"
B(44) = "L" : C(44) = "44" : S(44) = "b www bb w bbb w"
B(45) = "M" : C(45) = "45" : S(45) = "b w bbb w bb www"
B(46) = "N" : C(46) = "46" : S(46) = "b w bbb www bb w"
B(47) = "O" : C(47) = "47" : S(47) = "b www bbb w bb w"
B(48) = "P" : C(48) = "48" : S(48) = "bbb w bbb w bb w"
B(49) = "Q" : C(49) = "49" : S(49) = "bb w b www bbb w"
B(50) = "R" : C(50) = "50" : S(50) = "bb www b w bbb w"
B(51) = "S" : C(51) = "51" : S(51) = "bb w bbb w b www"
B(52) = "T" : C(52) = "52" : S(52) = "bb w bbb www b w"
B(53) = "U" : C(53) = "53" : S(53) = "bb w bbb w bbb w"
B(54) = "V" : C(54) = "54" : S(54) = "bbb w b w bb www"
B(55) = "W" : C(55) = "55" : S(55) = "bbb w b www bb w"
B(56) = "X" : C(56) = "56" : S(56) = "bbb www b w bb w"
B(57) = "Y" : C(57) = "57" : S(57) = "bbb w bb w b www"
B(58) = "Z" : C(58) = "58" : S(58) = "bbb w bb www b w"
B(59) = "[" : C(59) = "59" : S(59) = "bbb www bb w b w"
B(60) = "\" : C(60) = "60" : S(60) = "bbb w bbbb w b w"
B(61) = "]" : C(61) = "61" : S(61) = "bb ww b wwww b w"
B(62) = "^" : C(62) = "62" : S(62) = "bbbb www b w b w"
B(63) = "_" : C(63) = "63" : S(63) = "b w b ww bb wwww"
B(64) = "`" : C(64) = "64" : S(64) = "b w b wwww bb ww"
B(65) = "a" : C(65) = "65" : S(65) = "b ww b w bb wwww"
B(66) = "b" : C(66) = "66" : S(66) = "b ww b wwww bb w"
B(67) = "c" : C(67) = "67" : S(67) = "b wwww b w bb ww"
B(68) = "d" : C(68) = "68" : S(68) = "b wwww b ww bb w"
B(69) = "e" : C(69) = "69" : S(69) = "b w bb ww b wwww"
B(70) = "f" : C(70) = "70" : S(70) = "b w bb wwww b ww"
B(71) = "g" : C(71) = "71" : S(71) = "b ww bb w b wwww"
B(72) = "h" : C(72) = "72" : S(72) = "b ww bb wwww b w"
B(73) = "i" : C(73) = "73" : S(73) = "b wwww bb w b ww"
B(74) = "j" : C(74) = "74" : S(74) = "b wwww bb ww b w"
B(75) = "k" : C(75) = "75" : S(75) = "bb wwww b ww b w"
B(76) = "l" : C(76) = "76" : S(76) = "bb ww b w b wwww"
B(77) = "m" : C(77) = "77" : S(77) = "bbbb w bbb w b w"
B(78) = "n" : C(78) = "78" : S(78) = "bb wwww b w b ww"
B(79) = "o" : C(79) = "79" : S(79) = "b www bbbb w b w"
B(80) = "p" : C(80) = "80" : S(80) = "b w b ww bbbb ww"
B(81) = "q" : C(81) = "81" : S(81) = "b ww b w bbbb ww"
B(82) = "r" : C(82) = "82" : S(82) = "b ww b ww bbbb w"
B(83) = "s" : C(83) = "83" : S(83) = "b w bbbb ww b ww"
B(84) = "t" : C(84) = "84" : S(84) = "b ww bbbb w b ww"
B(85) = "u" : C(85) = "85" : S(85) = "b ww bbbb ww b w"
B(86) = "v" : C(86) = "86" : S(86) = "bbbb w b ww b ww"
B(87) = "w" : C(87) = "87" : S(87) = "bbbb ww b w b ww"
B(88) = "x" : C(88) = "88" : S(88) = "bbbb ww b ww b w"
B(89) = "y" : C(89) = "89" : S(89) = "bb w bb w bbbb w"
B(90) = "z" : C(90) = "90" : S(90) = "bb w bbbb w bb w"
B(91) = "{" : C(91) = "91" : S(91) = "bbbb w bb w bb w"
B(92) = "|" : C(92) = "92" : S(92) = "b w b w bbbb www"
B(93) = "}" : C(93) = "93" : S(93) = "b w b www bbbb w"
B(94) = "~" : C(94) = "94" : S(94) = "b www b w bbbb w"
'these code are not yet implemented
B(95) = "del" : C(95) = "95" : S(95) = "b w bbbb w b www"
B(96) = "func3" : C(96) = "96" : S(96) = "b w bbbb www b w"
B(97) = "func2" : C(97) = "97" : S(97) = "bbbb w b w b www"
B(98) = "Shift" : C(98) = "98" : S(98) = "bbbb w b www b w"
B(99) = "Code C" : C(99) = "99" : S(99) = "b w bbb w bbbb w"
B(100) = "func4" : C(100) = "Code B" : S(100) = "b w bbbb w bbb w"
B(101) = "Code A" : C(101) = "Code A" : S(101) = "bbb w b w bbbb w"
B(102) = "func1" : C(102) = "func1" : S(102) = "bbbb w b w bbb w"
B(103) = "Start A" : C(103) = "Start A" : S(103) = "bb w b wwww b ww"
'starting sign
B(104) = "Start B" : C(104) = "Start B" : S(104) = "bb w b ww b wwww"
'not implemented yet
B(105) = "Start C" : C(105) = "Start C" : S(105) = "bb w b ww bbb ww"
'very important...
B(106) = "Stop" : C(106) = "Stop" : S(106) = "bb www bbb w b w bb"
If foo = "" Then
MsgBox("Error has occured!") ' no string ;-(
Exit Function
End If
w(0) = "104" 'start
check = 104 'start check value
l = foo.Length
For n = 1 To l
For i = 0 To 94
If foo.Substring(n - 1, 1) = B(i) Then
w(n) = C(i)
Exit For
End If
Next
check = check + n * CInt(C(i))
'MsgBox(CStr(n * CInt(C(i))))
Next
'MsgBox(CStr(check))
l = l + 1
w(l) = C(check Mod 103) 'checkzahl - check number
l = l + 1
w(l) = "106" 'stop
Dim p As String = ""
For n = 0 To l
p = p + CStr(w(n)) & " "
Next
'MsgBox(p)
For n = 0 To l
Code128B = Code128B + S(CInt(w(n))) & " " 'ascii pendant basseln
Next
Code128B = Replace(Code128B, " ", "")
Return Code128B
End Function
'GENERATE THE BARCODE IMAGE IN PICTURE BOX
Private Function Code128Malen(c As String) As Image
'convert string (b and w´s) to graphics
Const w = 2
Dim n, l As Integer
l = c.Length
Dim bm As New Bitmap(l * w, 80)
Dim g As Graphics = Graphics.FromImage(bm)
For n = 0 To l - 1
If c.Substring(n, 1) = "b" Then g.FillRectangle(Brushes.White, n * w, 0, w, 80)
Next
Return bm
End Function
'PRINT OUT BARCODE
Private Sub printdocument_printpage()
PrintDocument1.Print()
End Sub
'CHANGE LABEL WHEN TEXBOX TEXT IS CHANGED
Private Sub textinput_TextChanged(sender As Object, e As EventArgs) Handles textinput.TextChanged
Label2.Text = textinput.Text
End Sub
'SAVE BARCODE IMAGE
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim MyPicture As Image
PictureBox1.Refresh()
MyPicture = PictureBox1.Image
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "jpegs|*.jpg|gifs|*.gif|bitmaps|*.bmp"
saveFileDialog1.FilterIndex = 1
saveFileDialog1.RestoreDirectory = True
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
MyPicture.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
End Sub
'CLOSE MENU FORM
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
'GO BACK TO MAIN MENU SCREEN
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Main_Menu.Show()
Me.Hide()
End Sub
'SAVE IMAGE AS A BARCODE
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim mypicture2 As Image
PictureBox2.Refresh()
mypicture2 = PictureBox2.Image
Dim savefiledialog2 As New SaveFileDialog()
savefiledialog2.Filter = "jpeg|*.jpeg|gif|*.gif|bmp|*.bmp"
savefiledialog2.FilterIndex = 1
savefiledialog2.RestoreDirectory = True
If savefiledialog2.ShowDialog() = Windows.Forms.DialogResult.OK Then
mypicture2.Save(savefiledialog2.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
End Sub
'PRINT OUT DOCUMENT BUTTON
'Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Dim g As Graphics =
' g.DrawImage(PictureBox1.Image, New Point(100, 100))
'End Sub
'CHANGE LABEL WHEN TEXTBOX TEXT IS CHANGED
Private Sub Textinput2_TextChanged(sender As Object, e As EventArgs) Handles Textinput2.TextChanged
Label3.Text = Textinput2.Text
End Sub
'GENERATE BARCODE WHEN CLICKED 2
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
TextBoxstring2.Text = Code128B(Textinput2.Text)
PictureBox2.Image = Code128Malen(TextBoxstring2.Text)
End Sub
'SECOND CODE MALEN 2
Private Function Code128Malen2(c As String) As Image
'convert string (b and w´s) to graphics
Const w = 2
Dim n, l As Integer
l = c.Length
Dim bmm As New Bitmap(l * w, 80)
Dim gg As Graphics = Graphics.FromImage(bmm)
For n = 0 To l - 1
If c.Substring(n, 1) = "b" Then gg.FillRectangle(Brushes.White, n * w, 0, w, 80)
Next
Return bmm
End Function
'GENERATE BARCODE STRING 2
Private Function Code128B2(foo As String) As String
Dim C(107) As String
Dim B(107) As String
Dim S(107) As String
Dim w(255) As String
Dim l As Integer = 0
Dim t As String = ""
Dim n, i As Integer
Dim check As Long = 0
Code128B2 = ""
B(0) = " " : C(0) = "00" : S(0) = "bb w bb ww bb ww"
B(1) = "!" : C(1) = "01" : S(1) = "bb ww bb w bb ww"
B(2) = Chr(34) : C(2) = "02" : S(2) = "bb ww bb ww bb w"
B(3) = "#" : C(3) = "03" : S(3) = "b ww b ww bb www"
B(4) = "$" : C(4) = "04" : S(4) = "b ww b www bb ww"
B(5) = "%" : C(5) = "05" : S(5) = "b www b ww bb ww"
B(6) = "&" : C(6) = "06" : S(6) = "b ww bb ww b www"
B(7) = "'" : C(7) = "07" : S(7) = "b ww bb www b ww"
B(8) = "(" : C(8) = "08" : S(8) = "b www bb ww b ww"
B(9) = ")" : C(9) = "09" : S(9) = "bb ww b ww b www"
B(10) = "*" : C(10) = "10" : S(10) = "bb ww b www b ww"
B(11) = "+" : C(11) = "11" : S(11) = "bb www b ww b ww"
B(12) = "," : C(12) = "12" : S(12) = "b w bb ww bbb ww"
B(13) = "-" : C(13) = "13" : S(13) = "b ww bb w bbb ww"
B(14) = "." : C(14) = "14" : S(14) = "b ww bb ww bbb w"
B(15) = "/" : C(15) = "15" : S(15) = "b w bbb ww bb ww"
B(16) = "0" : C(16) = "16" : S(16) = "b ww bbb w bb ww"
B(17) = "1" : C(17) = "17" : S(17) = "b ww bbb ww bb w"
B(18) = "2" : C(18) = "18" : S(18) = "bb ww bbb ww b w"
B(19) = "3" : C(19) = "19" : S(19) = "bb ww b w bbb ww"
B(20) = "4" : C(20) = "20" : S(20) = "bb ww b ww bbb w"
B(21) = "5" : C(21) = "21" : S(21) = "bb w bbb ww b ww"
B(22) = "6" : C(22) = "22" : S(22) = "bb ww bbb w b ww"
B(23) = "7" : C(23) = "23" : S(23) = "bbb w bb w bbb w"
B(24) = "8" : C(24) = "24" : S(24) = "bbb w b ww bb ww"
B(25) = "9" : C(25) = "25" : S(25) = "bbb ww b w bb ww"
B(26) = ":" : C(26) = "26" : S(26) = "bbb ww b ww bb w"
B(27) = ";" : C(27) = "27" : S(27) = "bbb w bb ww b ww"
B(28) = "<" : C(28) = "28" : S(28) = "bbb ww bb w b ww"
B(29) = "=" : C(29) = "29" : S(29) = "bbb ww bb ww b w"
B(30) = ">" : C(30) = "30" : S(30) = "bb w bb w bb www"
B(31) = "?" : C(31) = "31" : S(31) = "bb w bb www bb w"
B(32) = "@" : C(32) = "32" : S(32) = "bb www bb w bb w"
B(33) = "A" : C(33) = "33" : S(33) = "b w b www bb www"
B(34) = "B" : C(34) = "34" : S(34) = "b www b w bb www"
B(35) = "C" : C(35) = "35" : S(35) = "b www b www bb w"
B(36) = "D" : C(36) = "36" : S(36) = "b w bb www b www"
B(37) = "E" : C(37) = "37" : S(37) = "b www bb w b www"
B(38) = "F" : C(38) = "38" : S(38) = "b www bb www b w"
B(39) = "G" : C(39) = "39" : S(39) = "bb w b www b www"
B(40) = "H" : C(40) = "40" : S(40) = "bb www b w b www"
B(41) = "I" : C(41) = "41" : S(41) = "bb www b www b w"
B(42) = "J" : C(42) = "42" : S(42) = "b w bb w bbb www"
B(43) = "K" : C(43) = "43" : S(43) = "b w bb www bbb w"
B(44) = "L" : C(44) = "44" : S(44) = "b www bb w bbb w"
B(45) = "M" : C(45) = "45" : S(45) = "b w bbb w bb www"
B(46) = "N" : C(46) = "46" : S(46) = "b w bbb www bb w"
B(47) = "O" : C(47) = "47" : S(47) = "b www bbb w bb w"
B(48) = "P" : C(48) = "48" : S(48) = "bbb w bbb w bb w"
B(49) = "Q" : C(49) = "49" : S(49) = "bb w b www bbb w"
B(50) = "R" : C(50) = "50" : S(50) = "bb www b w bbb w"
B(51) = "S" : C(51) = "51" : S(51) = "bb w bbb w b www"
B(52) = "T" : C(52) = "52" : S(52) = "bb w bbb www b w"
B(53) = "U" : C(53) = "53" : S(53) = "bb w bbb w bbb w"
B(54) = "V" : C(54) = "54" : S(54) = "bbb w b w bb www"
B(55) = "W" : C(55) = "55" : S(55) = "bbb w b www bb w"
B(56) = "X" : C(56) = "56" : S(56) = "bbb www b w bb w"
B(57) = "Y" : C(57) = "57" : S(57) = "bbb w bb w b www"
B(58) = "Z" : C(58) = "58" : S(58) = "bbb w bb www b w"
B(59) = "[" : C(59) = "59" : S(59) = "bbb www bb w b w"
B(60) = "\" : C(60) = "60" : S(60) = "bbb w bbbb w b w"
B(61) = "]" : C(61) = "61" : S(61) = "bb ww b wwww b w"
B(62) = "^" : C(62) = "62" : S(62) = "bbbb www b w b w"
B(63) = "_" : C(63) = "63" : S(63) = "b w b ww bb wwww"
B(64) = "`" : C(64) = "64" : S(64) = "b w b wwww bb ww"
B(65) = "a" : C(65) = "65" : S(65) = "b ww b w bb wwww"
B(66) = "b" : C(66) = "66" : S(66) = "b ww b wwww bb w"
B(67) = "c" : C(67) = "67" : S(67) = "b wwww b w bb ww"
B(68) = "d" : C(68) = "68" : S(68) = "b wwww b ww bb w"
B(69) = "e" : C(69) = "69" : S(69) = "b w bb ww b wwww"
B(70) = "f" : C(70) = "70" : S(70) = "b w bb wwww b ww"
B(71) = "g" : C(71) = "71" : S(71) = "b ww bb w b wwww"
B(72) = "h" : C(72) = "72" : S(72) = "b ww bb wwww b w"
B(73) = "i" : C(73) = "73" : S(73) = "b wwww bb w b ww"
B(74) = "j" : C(74) = "74" : S(74) = "b wwww bb ww b w"
B(75) = "k" : C(75) = "75" : S(75) = "bb wwww b ww b w"
B(76) = "l" : C(76) = "76" : S(76) = "bb ww b w b wwww"
B(77) = "m" : C(77) = "77" : S(77) = "bbbb w bbb w b w"
B(78) = "n" : C(78) = "78" : S(78) = "bb wwww b w b ww"
B(79) = "o" : C(79) = "79" : S(79) = "b www bbbb w b w"
B(80) = "p" : C(80) = "80" : S(80) = "b w b ww bbbb ww"
B(81) = "q" : C(81) = "81" : S(81) = "b ww b w bbbb ww"
B(82) = "r" : C(82) = "82" : S(82) = "b ww b ww bbbb w"
B(83) = "s" : C(83) = "83" : S(83) = "b w bbbb ww b ww"
B(84) = "t" : C(84) = "84" : S(84) = "b ww bbbb w b ww"
B(85) = "u" : C(85) = "85" : S(85) = "b ww bbbb ww b w"
B(86) = "v" : C(86) = "86" : S(86) = "bbbb w b ww b ww"
B(87) = "w" : C(87) = "87" : S(87) = "bbbb ww b w b ww"
B(88) = "x" : C(88) = "88" : S(88) = "bbbb ww b ww b w"
B(89) = "y" : C(89) = "89" : S(89) = "bb w bb w bbbb w"
B(90) = "z" : C(90) = "90" : S(90) = "bb w bbbb w bb w"
B(91) = "{" : C(91) = "91" : S(91) = "bbbb w bb w bb w"
B(92) = "|" : C(92) = "92" : S(92) = "b w b w bbbb www"
B(93) = "}" : C(93) = "93" : S(93) = "b w b www bbbb w"
B(94) = "~" : C(94) = "94" : S(94) = "b www b w bbbb w"
'these code are not yet implemented
B(95) = "del" : C(95) = "95" : S(95) = "b w bbbb w b www"
B(96) = "func3" : C(96) = "96" : S(96) = "b w bbbb www b w"
B(97) = "func2" : C(97) = "97" : S(97) = "bbbb w b w b www"
B(98) = "Shift" : C(98) = "98" : S(98) = "bbbb w b www b w"
B(99) = "Code C" : C(99) = "99" : S(99) = "b w bbb w bbbb w"
B(100) = "func4" : C(100) = "Code B" : S(100) = "b w bbbb w bbb w"
B(101) = "Code A" : C(101) = "Code A" : S(101) = "bbb w b w bbbb w"
B(102) = "func1" : C(102) = "func1" : S(102) = "bbbb w b w bbb w"
B(103) = "Start A" : C(103) = "Start A" : S(103) = "bb w b wwww b ww"
'starting sign
B(104) = "Start B" : C(104) = "Start B" : S(104) = "bb w b ww b wwww"
'not implemented yet
B(105) = "Start C" : C(105) = "Start C" : S(105) = "bb w b ww bbb ww"
'very important...
B(106) = "Stop" : C(106) = "Stop" : S(106) = "bb www bbb w b w bb"
If foo = "" Then
MsgBox("Error has occured!") ' no string ;-(
Exit Function
End If
w(0) = "104" 'start
check = 104 'start check value
l = foo.Length
For n = 1 To l
For i = 0 To 94
If foo.Substring(n - 1, 1) = B(i) Then
w(n) = C(i)
Exit For
End If
Next
check = check + n * CInt(C(i))
'MsgBox(CStr(n * CInt(C(i))))
Next
'MsgBox(CStr(check))
l = l + 1
w(l) = C(check Mod 103) 'checkzahl - check number
l = l + 1
w(l) = "106" 'stop
Dim p As String = ""
For n = 0 To l
p = p + CStr(w(n)) & " "
Next
'MsgBox(p)
For n = 0 To l
Code128B2 = Code128B2 + S(CInt(w(n))) & " " 'ascii pendant basseln
Next
Code128B2 = Replace(Code128B2, " ", "")
Return Code128B2
End Function
Private Sub btngenerate_Click(sender As Object, e As EventArgs) Handles btngenerate.Click
textboxstring.Text = Code128B(textinput.Text)
PictureBox1.Image = Code128Malen(textboxstring.Text)
End Sub
Private Sub print_dialog1_Click(sender As Object, e As EventArgs) Handles print_dialog1.Click
PrintDialog1 = New PrintDialog
PrintDialog1.Document = PrintDocument1
Dim r As DialogResult = PrintDialog1.ShowDialog
If r = Windows.Forms.DialogResult.OK Then
PrintDocument1.Print()
End If
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawImage(PictureBox2.Image, 0, 0)
End Sub
End Class