-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
37 lines (34 loc) · 889 Bytes
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace BarCode
{
public partial class MainWin : Form
{
public MainWin()
{
InitializeComponent();
CRC.Text = Convert.ToString(GenerateCRC());
}
private void GetCRC(object sender, EventArgs e)
{
CRC.Text = Convert.ToString(GenerateCRC());
}
private int GenerateCRC()
{
int i, j, ctrlcode = 0;
string bc = BarCodeField.Text;
for (i = 0; i < 12; i++)
{
j = 9 - (i % 2) * 2;
ctrlcode += ((int)bc[i]-48) * j;
}
ctrlcode %= 10;
return ctrlcode;
}
}
}