io ho creato due funzioni che ti permettono di ottenere il valore binario da un numero e videversa
Ecco il codice
Function ConvertStringToBinCode(ByVal sBinCode As String) As String
Dim inputstr As New TextBox
inputstr.Text = sBinCode
Dim out As String
Dim d As Integer = -1
If inputstr.Text = 1 Then
Return 1
ElseIf inputstr.Text = 0 Then
Return 0
End If
While inputstr.Text = 1 = False
Math.DivRem(CInt(inputstr.Text), 2, d)
If out = -1 Then
out = d
Else
out &= d
End If
inputstr.Text = CUInt(inputstr.Text) \ 2
End While
Return StrReverse(out & 1)
End Function
Function DeconvertBinCodeToString(ByVal sBinCode As String) As String
Dim inputstr As New TextBox
inputstr.Text = sBinCode
Dim out As String
For x As Integer = 0 To inputstr.Text.Length - 1
out = out * 2 + inputstr.Text(x).ToString
Next
Return out
End Function
Spero d'esserti stato utile
|