# IMEI-Validator in VB.NET Posted by in Windows Forms category on for Intermediate level | Views : 14142 This article will explain how to validate a valid IMEI number of a mobile phone through VB.NET.

IMEI (International Mobile Equipment Identity) Code is a unique 15 Digit number which is usually found printed on the back side of the GSM/CDMA mobile phones battery.
The Logic behind identifying a correct IMEI Code is very simple.
The structure of the IMEI code is

AAAAAAAA - BBBBBB - C
AAAAAAAA = Type Allocation Code - The Type Allocation Code is an 8-digit number that identifies a particular model of wireless telephone for use on a GSM wireless network.

BBBBBB - Serial sequence of the model

And the most Important of All

C -The last number of the IMEI is a check digit calculated using the Luhn algorithm.
The check digit is validated in 3 steps:

1. Starting from the right, double a digit every second digits (e.g., 8 ? 16).
2. Sum the digits (e.g., 16 ? 1 + 6).
3. Check if the sum is divisible by 10.

Conversely, one can calculate the IMEI by choosing the check digit that would give a sum divisible by 10. For the example IMEI 352048021523553,

 IMEI Double Every Second Digit Sum digits 3 5 2 0 4 8 0 2 1 5 2 3 5 5 ? 3 10 2 0 4 16 0 4 1 10 2 6 5 10 ? 3+1+0+2+0+4+1+6+0+4+1+1+0+2+6+5+1+0 = 37

To make the sum divisible by 10, we set ? = 3, so the IMEI is .352048021523553

The reason I am writing this article is I had to develop a application for one of my client who was a mobile dealer and he had a requirement to check the IMEI of the mobiles he takes for sales or services.
Below is the code to Check a Valid IMEI code in VB.NET
In the TextBox Change Event of the TextBox where you want the user to enter the IMEI code type the following code.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

If TextBox1.Text.Length = 15 Then

Dim IMEI As String = TextBox1.Text

Dim cnt As Integer = 0

Dim nw As String = “” For Each c As Char In

IMEIcnt += 1
If cnt Mod 2 <> 0
Then
nw += c
Else
Dim d As Integer = Integer
.Parse(c) * 2nw += d.ToString()
End If Next Dim tot As Integer = 0

For Each ch As Char In nw.Remove(nw.Length - 1, 1)

tot +=
Integer.Parse(ch)

Next
Dim chDigit As Integer = 10 - (tot Mod 10)

If chDigit = Integer.Parse(IMEI(IMEI.Length - 1)) Then

MsgBox(“Valid”)

Else

MsgBox(“Invalid”)

End If
End
If
End
Sub

Regards
Hefin Dsouza Full Name: Hefin Dsouza
Member Level: Starter
Member Status: Member
Member Since: 9/16/2009 12:32:23 PM
Country: India

http://hefin.in
My Name is Hefin Dsouza. I am a faculty at Computer Education Institute.I am also an Freelance Software Developer and Software Trainner.I am working with DotNet Technologies from the past 8 years.I am an Microsoft Certified Windows Application Developer for .NET 3.5. And also a Blogger at http://blog.hefin.in

Login to vote for this post.

Comment using (Author doesn't get notification)