میتونید به جای dll از کلاس توی تایپیک 4 استفاده کنید
و طریقه استفاده هم شبیه dll است وی ا فقط تابع موجود در کلاس رو به صورت مجزا در هر جا که میخواهین کپی کنید و استفاده کنید
public bool chek(string meli)
{
try
{
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a, b;
int sum, mm;
char[] code = new char[12];
if (meli == "1111111111" || meli == "2222222222"||
meli == "3333333333" || meli == "4444444444"||
meli == "5555555555" ||meli == "6666666666" ||
meli == "7777777777" || meli == "8888888888"||
meli == "9999999999" || meli == "0000000000")
return false;
code = meli.ToCharArray();
///////////////////////////////
a1 = Convert.ToInt32(code[0].ToString()) * 10;//سه رقم اول
a2 = Convert.ToInt32(code[1].ToString()) * 9;//
a3 = Convert.ToInt32(code[2].ToString()) * 8;//
//-----------------------
a4 = Convert.ToInt32(code[3].ToString()) * 7;//
a5 = Convert.ToInt32(code[4].ToString()) * 6;//
a6 = Convert.ToInt32(code[5].ToString()) * 5;//شش رقم میانی
a7 = Convert.ToInt32(code[6].ToString()) * 4;//
a8 = Convert.ToInt32(code[7].ToString()) * 3;//
a9 = Convert.ToInt32(code[8].ToString()) * 2;//
//------------------
a10 = Convert.ToInt32(code[9].ToString());//رقم اخر
sum = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9;
mm = (sum % 11);
if (mm < 2)
if (a10 == mm)
return true;
if (mm >= 2)
if ((11 - mm) == a10)
return true;
return false;
}
catch
{
return false;
}
}
که فراخونی اون هم به شکل زیر می باشد
if (chek(textBox1.Text) == true)
MessageBox.Show("کد ملی صحیح می باشد", "تایید", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("کد ملی صحیح نمی باشد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Warning);