Public Function GetCodigoProximidad(ByVal p_CodigoProximidad As String) As String 

        If True Then 
            Dim longitud As Integer, i As Integer, j As Integer 
            Dim tfc As Double, fc As Double 
            Dim bin As String, hex As String, binfc As String, cfc As String, codigo As String 
            Dim facility As String, numcard As String, bintot As String, id As String 
            bintot = "" 
            bin = "" 
            tfc = 0 

            codigo = p_CodigoProximidad.Substring(5, 7) 

            longitud = codigo.Length 


            For i = 0 To longitud - 1 
                hex = codigo.Substring(i, 1) 
                Select Case hex 
                    Case "0" 
                        bin = "0000" 
                        Exit Select 
                    Case "1" 
                        bin = "0001" 
                        Exit Select 
                    Case "2" 
                        bin = "0010" 
                        Exit Select 
                    Case "3" 
                        bin = "0011" 
                        Exit Select 
                    Case "4" 
                        bin = "0100" 
                        Exit Select 
                    Case "5" 
                        bin = "0101" 
                        Exit Select 
                    Case "6" 
                        bin = "0110" 
                        Exit Select 
                    Case "7" 
                        bin = "0111" 
                        Exit Select 
                    Case "8" 
                        bin = "1000" 
                        Exit Select 
                    Case "9" 
                        bin = "1001" 
                        Exit Select 
                    Case "A" 
                        bin = "1010" 
                        Exit Select 
                    Case "B" 
                        bin = "1011" 
                        Exit Select 
                    Case "C" 
                        bin = "1100" 
                        Exit Select 
                    Case "D" 
                        bin = "1101" 
                        Exit Select 
                    Case "E" 
                        bin = "1110" 
                        Exit Select 
                    Case "F" 
                        bin = "1111" 
                        Exit Select 
                End Select 


                bintot = bintot & bin 
            Next 

            binfc = Reverse(bintot).Substring(17, 8) 

            j = binfc.Length 

            i = 0 
            fc = 2 
            For Each c As Char In binfc 
                If c.ToString().Equals("1") Then 
                    fc = 2 
                    fc = Math.Pow(fc, i) 
                    tfc = fc + tfc 
                End If 
                i += 1 
            Next 


            If Convert.ToString(tfc).Length.Equals(2) Then 
                facility = "0" & Convert.ToString(tfc) 
            Else 
                facility = Convert.ToString(tfc) 
            End If 
            binfc = Reverse(bintot).Substring(1, 16) 

            j = binfc.Length 

            tfc = 0 

            i = 0 
            fc = 2 
            For Each c As Char In binfc 
                If c.ToString().Equals("1") Then 
                    fc = 2 
                    fc = Math.Pow(fc, i) 
                    tfc = fc + tfc 
                End If 
                i += 1 
            Next 

            Dim Pad As Char 
            Pad = "0"c 
            numcard = String.Format("00000", Convert.ToString(tfc)) 
            numcard = Convert.ToString(tfc).PadLeft(5, Pad) 


            id = facility & numcard 

            Return id 

        End If 
    End Function 



    Public Shared Function Reverse(ByVal text As [String]) As [String] 
        Dim cArray As Char() = text.ToCharArray() 
        Dim reverse__1 As String = [String].Empty 
        For i As Integer = cArray.Length - 1 To -1 + 1 Step -1 
            reverse__1 += cArray(i) 
        Next 
        Return reverse__1 
    End Function 
