Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

How to Paint a ScanBar CODE39 on Printer or PictureBox

Total Hit ( 2878)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
'Put this code at a module.
'Usage: PaintCodeBar39 Printer, Xpos, Ypos, BarsHeight, WidthFactor, Text, HumanRead
' Printer.EndDoc

Public Type C39
  char As String * 1
  bar(1 To 5) As Boolean
  spe(1 To 5) As Boolean ' 5th space for character gap
End Type

Dim CODE39(43) As C39

Sub InitArray()
  CODE39(0).char = "0"
  CODE39(0).bar(1) = False
  CODE39(0).spe(1) = False
  CODE39(0).bar(2) = False
  CODE39(0).spe(2) = True
  CODE39(0).bar(3) = True
  CODE39(0).spe(3) = False
  CODE39(0).bar(4) = True
  CODE39(0).spe(4) = False
  CODE39(0).bar(5) = False
  CODE39(0).spe(5) = False
  CODE39(1).char = "1"
  CODE39(1).bar(1) = True
  CODE39(1).spe(1) = False
  CODE39(1).bar(2) = False
  CODE39(1).spe(2) = True
  CODE39(1).bar(3) = False
  CODE39(1).spe(3) = False
  CODE39(1).bar(4) = False
  CODE39(1).spe(4) = False
  CODE39(1).bar(5) = True
  CODE39(1).spe(5) = False
  CODE39(2).char = "2"
  CODE39(2).bar(1) = False
  CODE39(2).spe(1) = False
  CODE39(2).bar(2) = True
  CODE39(2).spe(2) = True
  CODE39(2).bar(3) = False
  CODE39(2).spe(3) = False
  CODE39(2).bar(4) = False
  CODE39(2).spe(4) = False
  CODE39(2).bar(5) = True
  CODE39(2).spe(5) = False
  CODE39(3).char = "3"
  CODE39(3).bar(1) = True
  CODE39(3).spe(1) = False
  CODE39(3).bar(2) = True
  CODE39(3).spe(2) = True
  CODE39(3).bar(3) = False
  CODE39(3).spe(3) = False
  CODE39(3).bar(4) = False
  CODE39(3).spe(4) = False
  CODE39(3).bar(5) = False
  CODE39(3).spe(5) = False
  CODE39(4).char = "4"
  CODE39(4).bar(1) = False
  CODE39(4).spe(1) = False
  CODE39(4).bar(2) = False
  CODE39(4).spe(2) = True
  CODE39(4).bar(3) = True
  CODE39(4).spe(3) = False
  CODE39(4).bar(4) = False
  CODE39(4).spe(4) = False
  CODE39(4).bar(5) = True
  CODE39(4).spe(5) = False
  CODE39(5).char = "5"
  CODE39(5).bar(1) = True
  CODE39(5).spe(1) = False
  CODE39(5).bar(2) = False
  CODE39(5).spe(2) = True
  CODE39(5).bar(3) = True
  CODE39(5).spe(3) = False
  CODE39(5).bar(4) = False
  CODE39(5).spe(4) = False
  CODE39(5).bar(5) = False
  CODE39(5).spe(5) = False
  CODE39(6).char = "6"
  CODE39(6).bar(1) = False
  CODE39(6).spe(1) = False
  CODE39(6).bar(2) = True
  CODE39(6).spe(2) = True
  CODE39(6).bar(3) = True
  CODE39(6).spe(3) = False
  CODE39(6).bar(4) = False
  CODE39(6).spe(4) = False
  CODE39(6).bar(5) = False
  CODE39(6).spe(5) = False
  CODE39(7).char = "7"
  CODE39(7).bar(1) = False
  CODE39(7).spe(1) = False
  CODE39(7).bar(2) = False
  CODE39(7).spe(2) = True
  CODE39(7).bar(3) = False
  CODE39(7).spe(3) = False
  CODE39(7).bar(4) = True
  CODE39(7).spe(4) = False
  CODE39(7).bar(5) = True
  CODE39(7).spe(5) = False
  CODE39(8).char = "8"
  CODE39(8).bar(1) = True
  CODE39(8).spe(1) = False
  CODE39(8).bar(2) = False
  CODE39(8).spe(2) = True
  CODE39(8).bar(3) = False
  CODE39(8).spe(3) = False
  CODE39(8).bar(4) = True
  CODE39(8).spe(4) = False
  CODE39(8).bar(5) = False
  CODE39(8).spe(5) = False
  CODE39(9).char = "9"
  CODE39(9).bar(1) = False
  CODE39(9).spe(1) = False
  CODE39(9).bar(2) = True
  CODE39(9).spe(2) = True
  CODE39(9).bar(3) = False
  CODE39(9).spe(3) = False
  CODE39(9).bar(4) = True
  CODE39(9).spe(4) = False
  CODE39(9).bar(5) = False
  CODE39(9).spe(5) = False
  CODE39(10).char = "A"
  CODE39(10).bar(1) = True
  CODE39(10).spe(1) = False
  CODE39(10).bar(2) = False
  CODE39(10).spe(2) = False
  CODE39(10).bar(3) = False
  CODE39(10).spe(3) = True
  CODE39(10).bar(4) = False
  CODE39(10).spe(4) = False
  CODE39(10).bar(5) = True
  CODE39(10).spe(5) = False
  CODE39(11).char = "B"
  CODE39(11).bar(1) = False
  CODE39(11).spe(1) = False
  CODE39(11).bar(2) = True
  CODE39(11).spe(2) = False
  CODE39(11).bar(3) = False
  CODE39(11).spe(3) = True
  CODE39(11).bar(4) = False
  CODE39(11).spe(4) = False
  CODE39(11).bar(5) = True
  CODE39(11).spe(5) = False
  CODE39(12).char = "C"
  CODE39(12).bar(1) = True
  CODE39(12).spe(1) = False
  CODE39(12).bar(2) = True
  CODE39(12).spe(2) = False
  CODE39(12).bar(3) = False
  CODE39(12).spe(3) = True
  CODE39(12).bar(4) = False
  CODE39(12).spe(4) = False
  CODE39(12).bar(5) = False
  CODE39(12).spe(5) = False
  CODE39(13).char = "D"
  CODE39(13).bar(1) = False
  CODE39(13).spe(1) = False
  CODE39(13).bar(2) = False
  CODE39(13).spe(2) = False
  CODE39(13).bar(3) = True
  CODE39(13).spe(3) = True
  CODE39(13).bar(4) = False
  CODE39(13).spe(4) = False
  CODE39(13).bar(5) = True
  CODE39(13).spe(5) = False
  CODE39(14).char = "E"
  CODE39(14).bar(1) = True
  CODE39(14).spe(1) = False
  CODE39(14).bar(2) = False
  CODE39(14).spe(2) = False
  CODE39(14).bar(3) = True
  CODE39(14).spe(3) = True
  CODE39(14).bar(4) = False
  CODE39(14).spe(4) = False
  CODE39(14).bar(5) = False
  CODE39(14).spe(5) = False
  CODE39(15).char = "F"
  CODE39(15).bar(1) = False
  CODE39(15).spe(1) = False
  CODE39(15).bar(2) = True
  CODE39(15).spe(2) = False
  CODE39(15).bar(3) = True
  CODE39(15).spe(3) = True
  CODE39(15).bar(4) = False
  CODE39(15).spe(4) = False
  CODE39(15).bar(5) = False
  CODE39(15).spe(5) = False
  CODE39(16).char = "G"
  CODE39(16).bar(1) = False
  CODE39(16).spe(1) = False
  CODE39(16).bar(2) = False
  CODE39(16).spe(2) = False
  CODE39(16).bar(3) = False
  CODE39(16).spe(3) = True
  CODE39(16).bar(4) = True
  CODE39(16).spe(4) = False
  CODE39(16).bar(5) = True
  CODE39(16).spe(5) = False
  CODE39(17).char = "H"
  CODE39(17).bar(1) = True
  CODE39(17).spe(1) = False
  CODE39(17).bar(2) = False
  CODE39(17).spe(2) = False
  CODE39(17).bar(3) = False
  CODE39(17).spe(3) = True
  CODE39(17).bar(4) = True
  CODE39(17).spe(4) = False
  CODE39(17).bar(5) = False
  CODE39(17).spe(5) = False
  CODE39(18).char = "I"
  CODE39(18).bar(1) = False
  CODE39(18).spe(1) = False
  CODE39(18).bar(2) = True
  CODE39(18).spe(2) = False
  CODE39(18).bar(3) = False
  CODE39(18).spe(3) = True
  CODE39(18).bar(4) = True
  CODE39(18).spe(4) = False
  CODE39(18).bar(5) = False
  CODE39(18).spe(5) = False
  CODE39(19).char = "J"
  CODE39(19).bar(1) = False
  CODE39(19).spe(1) = False
  CODE39(19).bar(2) = False
  CODE39(19).spe(2) = False
  CODE39(19).bar(3) = True
  CODE39(19).spe(3) = True
  CODE39(19).bar(4) = True
  CODE39(19).spe(4) = False
  CODE39(19).bar(5) = False
  CODE39(19).spe(5) = False
  CODE39(20).char = "K"
  CODE39(20).bar(1) = True
  CODE39(20).spe(1) = False
  CODE39(20).bar(2) = False
  CODE39(20).spe(2) = False
  CODE39(20).bar(3) = False
  CODE39(20).spe(3) = False
  CODE39(20).bar(4) = False
  CODE39(20).spe(4) = True
  CODE39(20).bar(5) = True
  CODE39(20).spe(5) = False
  CODE39(21).char = "L"
  CODE39(21).bar(1) = False
  CODE39(21).spe(1) = False
  CODE39(21).bar(2) = True
  CODE39(21).spe(2) = False
  CODE39(21).bar(3) = False
  CODE39(21).spe(3) = False
  CODE39(21).bar(4) = False
  CODE39(21).spe(4) = True
  CODE39(21).bar(5) = True
  CODE39(21).spe(5) = False
  CODE39(22).char = "M"
  CODE39(22).bar(1) = True
  CODE39(22).spe(1) = False
  CODE39(22).bar(2) = True
  CODE39(22).spe(2) = False
  CODE39(22).bar(3) = False
  CODE39(22).spe(3) = False
  CODE39(22).bar(4) = False
  CODE39(22).spe(4) = True
  CODE39(22).bar(5) = False
  CODE39(22).spe(5) = False
  CODE39(23).char = "N"
  CODE39(23).bar(1) = False
  CODE39(23).spe(1) = False
  CODE39(23).bar(2) = False
  CODE39(23).spe(2) = False
  CODE39(23).bar(3) = True
  CODE39(23).spe(3) = False
  CODE39(23).bar(4) = False
  CODE39(23).spe(4) = True
  CODE39(23).bar(5) = True
  CODE39(23).spe(5) = False
  CODE39(24).char = "O"
  CODE39(24).bar(1) = True
  CODE39(24).spe(1) = False
  CODE39(24).bar(2) = False
  CODE39(24).spe(2) = False
  CODE39(24).bar(3) = True
  CODE39(24).spe(3) = False
  CODE39(24).bar(4) = False
  CODE39(24).spe(4) = True
  CODE39(24).bar(5) = False
  CODE39(24).spe(5) = False
  CODE39(25).char = "P"
  CODE39(25).bar(1) = False
  CODE39(25).spe(1) = False
  CODE39(25).bar(2) = True
  CODE39(25).spe(2) = False
  CODE39(25).bar(3) = True
  CODE39(25).spe(3) = False
  CODE39(25).bar(4) = False
  CODE39(25).spe(4) = True
  CODE39(25).bar(5) = False
  CODE39(25).spe(5) = False
  CODE39(26).char = "Q"
  CODE39(26).bar(1) = False
  CODE39(26).spe(1) = False
  CODE39(26).bar(2) = False
  CODE39(26).spe(2) = False
  CODE39(26).bar(3) = False
  CODE39(26).spe(3) = False
  CODE39(26).bar(4) = True
  CODE39(26).spe(4) = True
  CODE39(26).bar(5) = True
  CODE39(26).spe(5) = False
  CODE39(27).char = "R"
  CODE39(27).bar(1) = True
  CODE39(27).spe(1) = False
  CODE39(27).bar(2) = False
  CODE39(27).spe(2) = False
  CODE39(27).bar(3) = False
  CODE39(27).spe(3) = False
  CODE39(27).bar(4) = True
  CODE39(27).spe(4) = True
  CODE39(27).bar(5) = False
  CODE39(27).spe(5) = False
  CODE39(28).char = "S"
  CODE39(28).bar(1) = False
  CODE39(28).spe(1) = False
  CODE39(28).bar(2) = True
  CODE39(28).spe(2) = False
  CODE39(28).bar(3) = False
  CODE39(28).spe(3) = False
  CODE39(28).bar(4) = True
  CODE39(28).spe(4) = True
  CODE39(28).bar(5) = False
  CODE39(28).spe(5) = False
  CODE39(29).char = "T"
  CODE39(29).bar(1) = False
  CODE39(29).spe(1) = False
  CODE39(29).bar(2) = False
  CODE39(29).spe(2) = False
  CODE39(29).bar(3) = True
  CODE39(29).spe(3) = False
  CODE39(29).bar(4) = True
  CODE39(29).spe(4) = True
  CODE39(29).bar(5) = False
  CODE39(29).spe(5) = False
  CODE39(30).char = "U"
  CODE39(30).bar(1) = True
  CODE39(30).spe(1) = True
  CODE39(30).bar(2) = False
  CODE39(30).spe(2) = False
  CODE39(30).bar(3) = False
  CODE39(30).spe(3) = False
  CODE39(30).bar(4) = False
  CODE39(30).spe(4) = False
  CODE39(30).bar(5) = True
  CODE39(30).spe(5) = False
  CODE39(31).char = "V"
  CODE39(31).bar(1) = False
  CODE39(31).spe(1) = True
  CODE39(31).bar(2) = True
  CODE39(31).spe(2) = False
  CODE39(31).bar(3) = False
  CODE39(31).spe(3) = False
  CODE39(31).bar(4) = False
  CODE39(31).spe(4) = False
  CODE39(31).bar(5) = True
  CODE39(31).spe(5) = False
  CODE39(32).char = "W"
  CODE39(32).bar(1) = True
  CODE39(32).spe(1) = True
  CODE39(32).bar(2) = True
  CODE39(32).spe(2) = False
  CODE39(32).bar(3) = False
  CODE39(32).spe(3) = False
  CODE39(32).bar(4) = False
  CODE39(32).spe(4) = False
  CODE39(32).bar(5) = False
  CODE39(32).spe(5) = False
  CODE39(33).char = "X"
  CODE39(33).bar(1) = False
  CODE39(33).spe(1) = True
  CODE39(33).bar(2) = False
  CODE39(33).spe(2) = False
  CODE39(33).bar(3) = True
  CODE39(33).spe(3) = False
  CODE39(33).bar(4) = False
  CODE39(33).spe(4) = False
  CODE39(33).bar(5) = True
  CODE39(33).spe(5) = False
  CODE39(34).char = "Y"
  CODE39(34).bar(1) = True
  CODE39(34).spe(1) = True
  CODE39(34).bar(2) = False
  CODE39(34).spe(2) = False
  CODE39(34).bar(3) = True
  CODE39(34).spe(3) = False
  CODE39(34).bar(4) = False
  CODE39(34).spe(4) = False
  CODE39(34).bar(5) = False
  CODE39(34).spe(5) = False
  CODE39(35).char = "Z"
  CODE39(35).bar(1) = False
  CODE39(35).spe(1) = True
  CODE39(35).bar(2) = True
  CODE39(35).spe(2) = False
  CODE39(35).bar(3) = True
  CODE39(35).spe(3) = False
  CODE39(35).bar(4) = False
  CODE39(35).spe(4) = False
  CODE39(35).bar(5) = False
  CODE39(35).spe(5) = False
  CODE39(36).char = "-"
  CODE39(36).bar(1) = False
  CODE39(36).spe(1) = True
  CODE39(36).bar(2) = False
  CODE39(36).spe(2) = False
  CODE39(36).bar(3) = False
  CODE39(36).spe(3) = False
  CODE39(36).bar(4) = True
  CODE39(36).spe(4) = False
  CODE39(36).bar(5) = True
  CODE39(36).spe(5) = False
  CODE39(37).char = "."
  CODE39(37).bar(1) = True
  CODE39(37).spe(1) = True
  CODE39(37).bar(2) = False
  CODE39(37).spe(2) = False
  CODE39(37).bar(3) = False
  CODE39(37).spe(3) = False
  CODE39(37).bar(4) = True
  CODE39(37).spe(4) = False
  CODE39(37).bar(5) = False
  CODE39(37).spe(5) = False
  CODE39(38).char = " "
  CODE39(38).bar(1) = False
  CODE39(38).spe(1) = True
  CODE39(38).bar(2) = True
  CODE39(38).spe(2) = False
  CODE39(38).bar(3) = False
  CODE39(38).spe(3) = False
  CODE39(38).bar(4) = True
  CODE39(38).spe(4) = False
  CODE39(38).bar(5) = False
  CODE39(38).spe(5) = False
  CODE39(39).char = "$"
  CODE39(39).bar(1) = False
  CODE39(39).spe(1) = True
  CODE39(39).bar(2) = False
  CODE39(39).spe(2) = True
  CODE39(39).bar(3) = False
  CODE39(39).spe(3) = True
  CODE39(39).bar(4) = False
  CODE39(39).spe(4) = False
  CODE39(39).bar(5) = False
  CODE39(39).spe(5) = False
  CODE39(40).char = "/"
  CODE39(40).bar(1) = False
  CODE39(40).spe(1) = True
  CODE39(40).bar(2) = False
  CODE39(40).spe(2) = True
  CODE39(40).bar(3) = False
  CODE39(40).spe(3) = False
  CODE39(40).bar(4) = False
  CODE39(40).spe(4) = True
  CODE39(40).bar(5) = False
  CODE39(40).spe(5) = False
  CODE39(41).char = "+"
  CODE39(41).bar(1) = False
  CODE39(41).spe(1) = True
  CODE39(41).bar(2) = False
  CODE39(41).spe(2) = False
  CODE39(41).bar(3) = False
  CODE39(41).spe(3) = True
  CODE39(41).bar(4) = False
  CODE39(41).spe(4) = True
  CODE39(41).bar(5) = False
  CODE39(41).spe(5) = False
  CODE39(42).char = "%"
  CODE39(42).bar(1) = False
  CODE39(42).spe(1) = False
  CODE39(42).bar(2) = False
  CODE39(42).spe(2) = True
  CODE39(42).bar(3) = False
  CODE39(42).spe(3) = True
  CODE39(42).bar(4) = False
  CODE39(42).spe(4) = True
  CODE39(42).bar(5) = False
  CODE39(42).spe(5) = False
  CODE39(43).char = "*"
  CODE39(43).bar(1) = False
  CODE39(43).spe(1) = True
  CODE39(43).bar(2) = False
  CODE39(43).spe(2) = False
  CODE39(43).bar(3) = True
  CODE39(43).spe(3) = False
  CODE39(43).bar(4) = True
  CODE39(43).spe(4) = False
  CODE39(43).bar(5) = False
  CODE39(43).spe(5) = False
End Sub

Sub PaintCodeBar39(PictObj As Object, x, y, h, wf, text As String, tf)

  InitArray

  PictObj.ScaleMode = 3
  PictObj.CurrentX = x
  PictObj.CurrentY = y

  xpos = x
  ypos = y

  text = Trim(text)

  For j = 1 To Len(text)
    d = Mid(text, j, 1)
    N39 = AscTo39(d)
    If tf Then
      PictObj.CurrentX = xpos + (16 * wf - PictObj.TextWidth(d)) / 2
      PictObj.CurrentY = y + h
      PictObj.Print d
    End If
    'Plot 5 bars and 4 spaces and gap
    For bs = 1 To 5
      'Bar
      If CODE39(N39).bar(bs) Then
        w = 3 'Wide
      Else
        w = 1 'Narrow
      End If
      'Draw line for bar
      For i = 1 To w * wf
        PictObj.Line (xpos, ypos)-(xpos, ypos + h)
        xpos = xpos + 1
      Next
      'Space
      If CODE39(N39).spe(bs) Then
        xpos = xpos + 3 * wf 'Wide
      Else
        xpos = xpos + 1 * wf 'Narrow
      End If
    Next

  Next

End Sub


Function AscTo39(c)
  AscTo39 = -1
  If c >= "0" And c <= "9" Then
    AscTo39 = Val(c)
  Else
    c = UCase(c)
    If c >= "A" And c <= "Z" Then
      AscTo39 = Asc(c) - 55
    Else
      Select Case c
      Case "-"
        AscTo39 = 36
      Case "."
        AscTo39 = 37
      Case " "
        AscTo39 = 38
      Case "*"
        AscTo39 = 43
      Case "$"
        AscTo39 = 39
      Case "/"
        AscTo39 = 40
      Case "+"
        AscTo39 = 41
      Case "%"
        AscTo39 = 42
      End Select
    End If
  End If
End Function

Usage

Click here to copy the following block
'To try it put this on a form command

Private Sub Command1_Click()
  PaintCodeBar39 Printer, 0,0, 50, 2, "*ABCDE*", True
  Printer.EndDoc
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.