When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Friday, August 25, 2000

Dynamically Generating I25 Bar Codes, Part 2

By Daniel Goncalves

  • Read Part 1

  • In Part 1 we looked at creating the I25Encode() function. We now need to write our ASP code that will take the results of this function and display the correct bar codes!

    - continued -

    Creating An Apropriated Graphics Set
    Now we must create a simple graphics (GIF) set. One for the narrow bar (black, 2 pixels wide), one for the narrow space (white, 2 pixels wide), one for the wide bar (black, 4 pixels wide) and one for the wide space (white 4 pixels wide), all these graphics can have 39 pixels height or more. I have included a ZIP file containing these graphics. The file names are:

    File NameDescriptionImage
    nb.gifNarrow barnb.gif
    ns.gifNarrow spacens.gif
    wb.gifWide barwb.gif
    ws.gifWide spacews.gif
    These graphics will be used to generate the resulting HTTP that will mount the full barcode through <IMG ...> tags.

    Writing The Final Code
    Now we'll write the final code. This code will read the string returned by I25Encode() function and generate the resulting HTTP using our gifs. (While I don't show the I25Encode() function in the script below, it must be included (either cut and pasted into the file or via a server-side include.)

    <HEAD><TITLE>Interleaved 2-of-5 Example</TITLE></HEAD>
       ' Ensure that the I25Encode function is in this file...
       ' (For this example it has been removed for brevity
    <P><FONT FACE='Verdana, Arial' SIZE='1'>
    Enter the number to be encoded as Interleaved 2-of-5 Specification.
    <FORM NAME='I25' ACTION='i25.asp' METHOD='post'>
       <INPUT TYPE='text' NAME='txtNUM'>
       <INPUT TYPE='hidden' NAME='hidFORM' VALUE='fromFORM'>
       <INPUT TYPE='submit'>
    <P> </P>
    <P><FONT FACE='Verdana, Arial' SIZE='1'>
       If Request("hidFORM") = "fromFORM" Then
          sMyI25 = I25Encode(Request("txtNUM"))
          If (sMyI25 = "") Then
             Response.Write """" & Request("txtNUM") & _
                            """ is invalid. Try another number."
             Dim iPos, sGIF, bBAR
             bBAR = True
             For iPos = 1 To Len(sMyI25)
                 If (bBar) Then 
                    sGIF = Mid(sMyI25, iPos, 1) & "b.gif"
                    sGIF = Mid(sMyI25, iPos, 1) & "s.gif"
                 End If
                 Response.Write "<IMG SRC='" & sGIF & "'>"
                 bBar = Not bBar
          End if
       End If

    (If you are interested in seeing the results, go ahead and give the live demo a whirl!) Well done and Happy Programming!

  • By Daniel Goncalves


  • Try the live demo!
  • View the source for the I25Encode function in text format
  • Download the Bar graphics in ZIP format
  • Read Generating Dynamic Bar Code on a Web Page (using Code 39 barcodes)

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article