1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

IMEI Number validation using VB.NET

Discussion in 'Visual Basic .NET' started by dangerbear, Feb 15, 2012.

  1. dangerbear

    dangerbear Newbie

    Joined:
    Apr 3, 2011
    Messages:
    4
    Likes Received:
    1
    Occupation:
    Software Developer
    Location:
    India
    Hi ,

    I had this on my blog.
    blog(dot)hefin(dot)in

    I just felt like sharing this information here..for many programmers may be looking for codes like these.

    The Code Logic is very simple..

    Problem : Validating a Correct IMEI Number. (For those who dont know what IMEI stands google for IMEI.)

    Solution
    In the TextBox Change event 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
    
    Hope this code is useful.
     
  2. specopkirbs

    specopkirbs BANNED BANNED

    Joined:
    Nov 28, 2008
    Messages:
    920
    Likes Received:
    746
    You can also get the make and model from the imei. The imei contains the type allocation code which contains the handset info. There is an online database that contains all TACs that you can query against
     
  3. BingImIn

    BingImIn Newbie

    Joined:
    Feb 18, 2012
    Messages:
    10
    Likes Received:
    1
    Nice little tool, I'm sure it'll come in handy one day.