convert text to decimal

  • Thread starter Thread starter xla76
  • Start date Start date
X

xla76

Hi all,

I am trying to follow some instructions for setting a password for VNC.
unfortunately I get stuck at the first hurdle:
''DecimalPassword = your password converted to decimal, separated by
spaces. ie "255 255 255"'

How do I do that? I tried double.parse with no luck.

Thanks

Pete
 
You mean something like this:

Private Function Pwd2Dec(ByVal Pwd As String) As String
Dim MyPwd() As Char
Dim DecPwd As New System.Text.StringBuilder

MyPwd = Pwd.ToCharArray()
For i As Integer = 0 To MyPwd.GetUpperBound(0)
DecPwd.Append(Asc(MyPwd(i)).ToString & " ")
Next
Return DecPwd.ToString
End Function

Private Function Dec2Pwd(ByVal DecPwd As String) As String
Dim MyDec() As String = Split(DecPwd, " ")
Dim Pwd As New System.Text.StringBuilder

For i As Integer = 0 To MyDec.GetUpperBound(0)
'used cint(val(..)) instead of cint because it won't give a
type mismatch when the string isn't numeric
Pwd.Append(Chr(CInt(Val(MyDec(i)))))
Next
Return Pwd.ToString
End Function
 
I'm not sure what VNC is looking for, but I might guess that they want the
ASCII value of each character in the password. Try this code.

Dim password As String
Dim decimalPassword As String = ""
Dim counter As Integer

' ----- Get the password itself, somehow.
password = PromptUserForPassword()

' ----- Convert to decimal form.
For counter = 0 to password.Length - 1
If (counter > 0) Then decimalPassword &= " "
decimalPassword &= CStr(Asc(password.Substring(counter, 1)))
Next counter
 
Back
Top