ð
Master Visual Basic .NET and Access Database By Building the Point Of
Sale System (POS).
ðē Enroll Now: https://bit.ly/2WcbRhX
Visual Studio 2015: How to Create EAN 13 Barcode Generator.
✅ VB.Net version
» https://youtu.be/VTKS6f0RheU
✅ C Sharp version:
» https://youtu.be/6zo133qcu_Y
Visual Studio 2017 : Windows Forms Application.
✅ VB .Net & C# (Preview) Generating and Printing EAN-13 Barcodes in Crystal Reports.
» https://youtu.be/fjz3XroBmGo
Visual Studio 2017 : Windows Presentation Foundation (WPF).
✅ : C# (Preview) Generating and Printing EAN-13 Barcodes in Crystal Reports.
» https://youtu.be/KWlZE7WLJ7Y
✅ Visual Basic .Net (Preview) Generating and Printing EAN-13 Barcodes in Crystal Reports.
» https://youtu.be/s6tVYsOU2uA
ðĻðŧ Here is my online course: Visual Basic .NET (VB.NET), Access Database and Crystal Reports Course.
ðŊ Enroll now (Full lifetime access): http://bit.ly/2YRy99d
[Screenshot]
[C# Source Code]
Class : ChangeTextColor.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
namespace EAN13_Barcode_CSharp
{
class ChangeTextColor
{
public static void ChangeColor(RichTextBox rtx,
int Start, byte Length = 1)
{
rtx.SelectionAlignment =
HorizontalAlignment.Left;
rtx.SelectionStart = Start;
rtx.SelectionLength = Length;
rtx.SelectionColor =
Color.Crimson;
}
}
}
Class : EAN13Class.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace EAN13_Barcode_CSharp
{
class EAN13Class
{
public static string Barcode13Digits = "";
public static string EAN13(string chaine)
{
int i;
int first;
int checkSum = 0;
string Barcode = "";
bool tableA;
if (Regex.IsMatch(chaine,
"^\\d{12}$"))
{
for (i = 1; i <
12; i += 2)
{
System.Diagnostics.Debug.WriteLine(chaine.Substring(i, 1));
checkSum += Convert.ToInt32(chaine.Substring(i, 1));
}
checkSum *= 3;
for (i = 0; i <
12; i += 2)
{
checkSum += Convert.ToInt32(chaine.Substring(i, 1));
}
chaine += (10 -
checkSum % 10) % 10;
Barcode13Digits =
chaine.ToString();
Barcode =
chaine.Substring(0, 1) + (char)(65 + Convert.ToInt32(chaine.Substring(1,
1)));
first =
Convert.ToInt32(chaine.Substring(0, 1));
for (i = 2; i
<= 6; i++)
{
tableA = false;
switch (i)
{
case 2:
if (first >= 0 && first <= 3)
tableA = true;
break;
case 3:
if (first == 0 || first == 4 || first == 7 ||
first == 8) tableA = true;
break;
case 4:
if (first == 0 || first == 1 || first == 4 ||
first == 5 || first == 9) tableA = true;
break;
case 5:
if (first == 0 || first == 2 || first == 5 ||
first == 6 || first == 7) tableA = true;
break;
case 6:
if (first == 0 || first == 3 || first == 6 ||
first == 8 || first == 9) tableA = true;
break;
}
if
(tableA)
{
Barcode += (char)(65 + Convert.ToInt32(chaine.Substring(i,
1)));
}
else
{
Barcode += (char)(75 + Convert.ToInt32(chaine.Substring(i,
1)));
}
}
Barcode += "*";
for (i = 7; i
<= 12; i++)
{
Barcode += (char)(97 + Convert.ToInt32(chaine.Substring(i, 1)));
}
Barcode += "+";
}
return Barcode;
}
}
}
Form : Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EAN13_Barcode_CSharp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object
sender, EventArgs e)
{
string Barrcode, Check12Digits;
if (textBox1.Text != "")
{
Check12Digits =
textBox1.Text.PadRight(12, '0');
Barrcode =
EAN13Class.EAN13(Check12Digits);
label1.Text =
Barrcode;
if
(!String.Equals(EAN13Class.Barcode13Digits, "") ||
(EAN13Class.Barcode13Digits != ""))
{
richTextBox1.Text = EAN13Class.Barcode13Digits.ToString();
//
Change Color of certain text in a RighTextBox.
Int32 intStart = Convert.ToInt32(richTextBox1.TextLength - 1);
ChangeTextColor.ChangeColor(richTextBox1, intStart);
}
}
}
}
}
ð FOLLOW ME ON
Twitter
Facebook āē _āē
Facebook (✪Ï✪)
Facebook ā° _ā°
Google+
YouTube Channel
Dailymotion Channel
Free Source Code can be found here:
Thank you very much.
#CSharp #Programming #CodeAMinute #iBasskungTutorial #EAN13
#BarcodeGenerator #RetailPOS substring c# Substring vb.net
Comments
Post a Comment