Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Writing Barcodes
  1. Start Visual Studio .NET.
  2. Start with the project that you created in Reading Bar Codes Tutorial
  3. Drag and drop two button in Form1. Change the following properties: Property Value: Name: btnWriteBarCode Text: Write BarCode
  4. Add the following code for the btnWriteBarCode control’s click procedure:

    Visual Basic

    
    Private Sub btnWriteBarCode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWriteBarCode.Click
       Dim data(1) As String
       data(0) = "012345678901"
       Dim barWPDF As BarcodeWritePdf = New BarcodeWritePdf()
       Dim barWDM As BarcodeWriteDatamatrix = New BarcodeWriteDatamatrix()
       Dim barWQR As BarcodeWriteQr = New BarcodeWriteQr()
       Dim barColor As BarcodeColor = New BarcodeColor()
       Dim barData As BarcodeData = New BarcodeData()
       barData.Unit = BarcodeUnit.ScanlinesPerPixels
       barData.Location = New Rectangle(100, 100, 250, 150)
       barData.Data = BarcodeData.ConvertFromStringArray(data)
       Dim bar1d As Barcode1d = New Barcode1d()
       bar1d.ErrorCheck = True
       bar1d.OutShowText = True
    
       Try
          _barEngine.Write(_image, _
                           barData, _
                           barColor, _
                           BarcodeWriteFlags.None, _
                           bar1d, _
                           barWPDF, _
                           barWDM, _
                           barWQR, _
                           Rectangle.Empty)
          MessageBox.Show(Me, "Barcode is written")
       Catch ex As Exception
          MessageBox.Show(Me, ex.Message)
       End Try
    End Sub
    

    C#

    
    private void btnWriteBarCode_Click(object sender, EventArgs e)
    {
       string [] barcodeData = new string[1];
       barcodeData[0] = "012345678901";
       BarcodeWritePdf barWPDF = new BarcodeWritePdf();
       BarcodeWriteDatamatrix barWDM = new BarcodeWriteDatamatrix();
       BarcodeWriteQr barWQR = new BarcodeWriteQr();
       BarcodeColor barColor = new BarcodeColor();
       BarcodeData barData = new BarcodeData();
       barData.Unit = BarcodeUnit.ScanlinesPerPixels;
       barData.Location = new Rectangle(100, 100, 250, 150);
       barData.Data = BarcodeData.ConvertFromStringArray(barcodeData);
       Barcode1d bar1d = new Barcode1d();
       bar1d.ErrorCheck = true;
       bar1d.OutShowText = true;
    
       try
       {
          _barEngine.Write(_image,
                           barData,
                           barColor,
                           BarcodeWriteFlags.None,
                           bar1d,
                           barWPDF,
                           barWDM,
                           barWQR,
                           Rectangle.Empty);
          MessageBox.Show(this, "Barcode is written");
       }
       catch (Exception ex)
       {
          MessageBox.Show(this, ex.Message);
       }
    }