Using Format( ) function to format bar code data

The Visual Basic Format( ) function is a very powerful and flexible way to format values; text, number, date, etc.

Format(value, format_text)

The formatted result of the Format( ) function can be used with bar code functions, to automatically print bar codes containing exactly the characters you need.

Tip: Before you use bar code functions, use the Format( ) function to format results as text in a report or query, and when you get the formatting you want, then use the results in your bar code formulas.

Leading zeros

Tip: If we use leading zeros, to produce fixed length data, any resulting bar codes will all be the same length.

This code format values in A with up to 5 leading zeros and no decimal places;

A = 12
B$ = Format(A, "00000")

If A was 12, the result in B$ is 00012. We can use the result with a bar code function;

=CIA_CODE128(Format(A, "00000"))

to produce a Code 128 bar code containg 00012.

Dates

=Format(Now, "YYYYMMDD")

If the date was 07/04/01, the result would be 20010704.

Because the date is now formatted as all numeric, a numeric only bar code types to be used (e.g. Interleaved 2 of 5);

=CIA_ITF(Format(Now, "YYYYMMDD"))

this also produces smaller printed bar codes.

 


Copyright 2000 CIA (BAR CODES) UK. All rights reserved. Reproduction prohibited.