[C#][VB.NET]產生 Barcode

  • 30811
  • 0
  • 2010-08-03

[C#][VB.NET]產生 Barcode

 

一、問題描述

如何產生 BarCode

 

二、方法

處理此問題有兩個重點 : BarCode 字型與 BarCode 資料前後要加 *

1. 下載與安裝免費 BarCode 字型 (Code39)

http://www.squaregear.net/fonts/free3of9.shtml

image

image

 

2. 建立新專案,在 Form 中加入 TextBox1、Label1、Button1,在 Button1.Click 事件中,加入以下程式碼

VB.NET


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = "*" + UCase(TextBox1.Text) + "*"
        Label1.Font = New Font("Free 3 of 9", 20, Label1.Font.Style, Label1.Font.Unit)
    End Sub

 

C#

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = "*" + textBox1.Text.ToUpper() + "*";
            label1.Font = new Font("Free 3 of 9", 20, label1.Font.Style, label1.Font.Unit);
        }

 

3. 執行結果

(1) 輸入想要變成 Barcode 的文字到 TextBox1 中

(2) 按 Button1 產生 Barcode 於 Label1

image

 

三、相關連結與參考

MSDN 論壇 : 條碼的製作問題