[an error occurred while processing this directive]

The 3 of 9 code
 


V
ersion francaise

This code easy to use allows the coding of 43 characters : 10 digits, 26 capital letters, the symbols $ % + -. / and the space. The extend mode makes it possible to code the 128 ASCII characters ; in this mode characters added compared to the "simple" mode are coded with 2 characters.

Let's learn encoding system.

Character

Value

Pattern

Character

Value

Pattern

Character

Value

Pattern

0

0

 101000111011101

F

15

101110111000101

U

30

111000101010111

1

1

 111010001010111

G

16

 101010001110111

V

31

100011101010111

2

2

 101110001010111

H

17

 111010100011101

W

32

111000111010101

3

3

 111011100010101

I

18

 101110100011101

X

33

100010111010111

4

4

 101000111010111

J

19

 101011100011101

Y

34

111000101110101

5

5

 111010001110101

K

20

 111010101000111

Z

35

100011101110101

6

6

 101110001110101

L

21

 101110101000111

-

36

100010101110111

7

7

101000101110111

M

22

 111011101010001

.

37

111000101011101

8

8

 111010001011101

N

23

 101011101000111

Espace

38

100011101011101

9

9

 101110001011101

O

24

 111010111010001

$

39

100010001000101

A

10

 111010100010111

P

25

 101110111010001

/

40

100010001010001

B

11

101110100010111

Q

26

101010111000111

+

41

100010100010001

C

12

111011101000101

R

27

111010101110001

%

42

101000100010001

D

13

101011100010111

S

28

101110101110001

 

 

 

E

14

111010111000101

T

29

101011101110001

*

 

100010111011101

Exemple of checksum for : ZB65732
35 + 11 + 6 +5 +7 +3 +2 = 69
69 / 43 = 1, remainder 26 which corresponds to the letter Q
New code with the checksum : ZB65732Q

The extend mode.

The charaters not forming part of the simple mode are coded with one of the 4 prefix % $ / +  followed by a basic character according to the following table. To literally use the charaters which are used as prefix or the symbol * it will be necessary to use a coding on 2 characters.

Character to be produced

Sequence to be used

 

Character to be produced

Sequence to be used

 

Character to be produced

Sequence to be used

NUL

%U

 

+

/K

 

V

V

SOH

$A

 

,

/L

 

W

W

STX

$B

 

-

-

 

X

X

ETX

$C

 

.

.

 

Y

Y

EOT

$D

 

/

/O

 

Z

Z

ENQ

$E

 

0

0

 

[

%K

ACK

$F

 

1

1

 

\

%L

BEL

$G

 

2

2

 

]

%M

BS

$H

 

3

3

 

^

%N

HT

$I

 

4

4

 

_

%O

LF

$J

 

5

5

 

`

%W

VT

$K

 

6

6

 

a

+A

FF

$L

 

7

7

 

b

+B

CR

$M

 

8

8

 

c

+C

SO

$N

 

9

9

 

d

+D

SI

$O

 

:

/Z

 

e

+E

DLE

$P

 

;

%F

 

f

+F

DC1

$Q

 

<

%G

 

g

+G

DC2

$R

 

=

%H

 

h

+H

DC3

$S

 

>

%I

 

i

+I

DC4

$T

 

?

%J

 

j

+J

NAK

$U

 

@

%V

 

k

+K

SYN

$V

 

A

A

 

l

+L

ETB

$W

 

B

B

 

m

+M

CAN

$X

 

C

C

 

n

+N

EM

$Y

 

D

D

 

o

+O

SUB

$Z

 

E

E

 

p

+P

ESC

%A

 

F

F

 

q

+Q

FS

%B

 

G

G

 

r

+R

GS

%C

 

H

H

 

s

+S

RS

%D

 

I

I

 

t

+T

US

%E

 

J

J

 

u

+U

SPACE

SPACE

 

K

K

 

v

+V

!

/A

 

L

L

 

w

+W

"

/B

 

M

M

 

x

+X

#

/C

 

N

N

 

y

+Y

$

/D

 

O

O

 

z

+Z

%

/E

 

P

P

 

{

%P

&

/F

 

Q

Q

 

|

%Q

'

/G

 

R

R

 

}

%R

(

/H

 

S

S

 

~

%S

)

/I

 

T

T

 

DEL

%T

*

/J

 

U

U

 

 

 

Bar code making.

Since we can create the bar code pattern it remains us to draw it on the screen and to print it on a paper sheet. Two approaches are possible :

All the found 3 of 9 barcodes on the net (Incomplete demonstration font) aren't free, several times expensive, and with uncertain quality; the width module isn't always permanent  in the font definition. I've decided consequently to draw entirely a 3 of 9 font and to propose it for download. I test it on a laser printer with size 11, what gives a small barcode with a width of about 1,6 mm/car, result : reading at 100% ! On a good inkjet printer, we must go up to the size 15 what give a character width of 2,1mm.

The font " code39.ttf "

This font contain the 43 basic charactersand the delimitor under the symbol *. Each character ends with a fin white bar of separation.

Copy this file
in the font directory,
often named :
C:\WINDOWS\FONTS

Structure of a 3 of 9 barcode

A 3 of 9 barcode will be build up in the following way :

A small program to test basic mode

Here is a small program
written with Visual Basic 6.
The setup file copy the
program, the Visual Basic
dependencies, the source
files and the font.

 

Setup file :

ZIP file without setup :

This test program manages neither the extend mode nor the checksum.

The Code39$ function can be re-used in any other program written with Visual BASIC 6; it can also be copied just as it is in a VBA macro linked to an Excel or Word document.

Public Function Code39$(chaine$)
  'V 1.0.0
  'Parametres : une chaine
  'Parameters : a string
  'Retour : * une chaine qui, affichee avec la police CODE39.TTF, donne le code barre
  '         * une chaine vide si parametre fourni incorrect
  'Return : * a string which give the bar code when it is dispayed with CODE39.TTF font
  '         * an empty string if the supplied parameter is no good
  Dim i%
  Code39$ = ""
  If Len(chaine$) > 0 Then
  'Verifier si caracteres valides
  'Check for valid characters
    For i% = 1 To Len(chaine$)
      Select Case Asc(Mid$(chaine$, i%, 1))
      Case 32, 36, 37, 43, 45 To 57, 65 To 90
      Case Else
        i% = 0
        Exit For
      End Select
    Next
    If i% > 0 Then
      Code39$ = "*" & chaine$ & "*"
    End If
  End If
End Function

Sample file for Excel :
and with Open Office :

Since the first publication of this page, I'd received numbered versions in different languages :

Language

Author

Visual Foxpro

Emile MAITREJEAN

Delphi

Jean-Camille POPULUS
Francisco FERNANDEZ



Do you like this page ?

Is it useful for you
?

Click here !