3491842093
Instructor
Here's some code in VB that convert (siemens) Dect IPUI in IPEI:
Note that the code is not optimized. Anyone of you could make a better job than this. But, if U are lazy, simply copy-paste it.
What you need is a form, two textboxes (one named txtIPUI; the other one named TextBox1) and a command button (named Button1):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strDato As String
Dim strConvertito As String
Dim strPrima As String
Dim strSeconda As String
Dim StrUnificata As String
Dim i As Integer
Dim CONTROLLO As Integer
Dim test As Double
Dim PrimaParte As Double
Dim SecondaParte As Double
Dim convertito As String
txtIPUI.Text = UCase(txtIPUI.Text)
strDato = txtIPUI.Text
strPrima = Mid(strDato, 2, 4)
strSeconda = Mid(strDato, 6)
strPrima = Hex2Dec(strPrima)
strSeconda = Hex2Dec(strSeconda)
Do While Len(strPrima) < 5
strPrima = "0" & strPrima
Loop
Do While Len(strSeconda) < 7
strSeconda = "0" & strSeconda
Loop
StrUnificata = strPrima & strSeconda
For i = 1 To Len(StrUnificata)
test = test + (i * Val(Mid(StrUnificata, i, 1)))
Next
CONTROLLO = (Val(test) Mod 11)
convertito = StrUnificata & CStr(CONTROLLO)
TextBox1.Text = "IPEI= " & convertito
If Not Len(convertito) = 13 Then
MsgBox("Attention! Ipei lenght incorrect." & vbCrLf & "Verificare IPUI", MsgBoxStyle.Critical + vbOKOnly, "Damn!!!")
End If
End Sub
Public Function Hex2Dec(ByVal numero)
Dim n, i, cifra, decimale
decimale = 0
n = Len(numero)
For i = 1 To n
decimale = decimale * 16
cifra = Mid(numero, i, 1)
decimale = decimale + InStr("0123456789ABCDEF", cifra) - 1
Next
Hex2Dec = decimale
End Function
Note that the code is not optimized. Anyone of you could make a better job than this. But, if U are lazy, simply copy-paste it.
What you need is a form, two textboxes (one named txtIPUI; the other one named TextBox1) and a command button (named Button1):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strDato As String
Dim strConvertito As String
Dim strPrima As String
Dim strSeconda As String
Dim StrUnificata As String
Dim i As Integer
Dim CONTROLLO As Integer
Dim test As Double
Dim PrimaParte As Double
Dim SecondaParte As Double
Dim convertito As String
txtIPUI.Text = UCase(txtIPUI.Text)
strDato = txtIPUI.Text
strPrima = Mid(strDato, 2, 4)
strSeconda = Mid(strDato, 6)
strPrima = Hex2Dec(strPrima)
strSeconda = Hex2Dec(strSeconda)
Do While Len(strPrima) < 5
strPrima = "0" & strPrima
Loop
Do While Len(strSeconda) < 7
strSeconda = "0" & strSeconda
Loop
StrUnificata = strPrima & strSeconda
For i = 1 To Len(StrUnificata)
test = test + (i * Val(Mid(StrUnificata, i, 1)))
Next
CONTROLLO = (Val(test) Mod 11)
convertito = StrUnificata & CStr(CONTROLLO)
TextBox1.Text = "IPEI= " & convertito
If Not Len(convertito) = 13 Then
MsgBox("Attention! Ipei lenght incorrect." & vbCrLf & "Verificare IPUI", MsgBoxStyle.Critical + vbOKOnly, "Damn!!!")
End If
End Sub
Public Function Hex2Dec(ByVal numero)
Dim n, i, cifra, decimale
decimale = 0
n = Len(numero)
For i = 1 To n
decimale = decimale * 16
cifra = Mid(numero, i, 1)
decimale = decimale + InStr("0123456789ABCDEF", cifra) - 1
Next
Hex2Dec = decimale
End Function