[Help]Converting Char to Decimal[Solved]

Posts 1–3 of 3 · Page 1 of 1
[Help]Converting Char to Decimal[Solved]
For example if I input "a" into textbox1, it'll output "97" into textbox2.

Any help?
Got it working xD

I randomly changed the input trying to see if anything works and o_O it does work.

[php] Dim str As String = TextBox1.Text
Dim bytes() As Byte
Dim hexn As System.Text.StringBuilder = New System.Text.StringBuilder

bytes = System.Text.ASCIIEncoding.ASCII.GetBytes(str)

For i As Integer = 0 To bytes.Length - 1
hexn.Append(bytes(i).ToString("d"))
Next

MsgBox((hexn.ToString()))[/php]

ToString("x") <- Hex
ToString("d") <- Decimal

I just tried d and it worked o_O I was like wtf xD

Well there you go

// As function
[php]
private function todecimal(byval text as string)

Dim str As String = text
Dim bytes() As Byte
Dim hexn As System.Text.StringBuilder = New System.Text.StringBuilder

bytes = System.Text.ASCIIEncoding.ASCII.GetBytes(str)

For i As Integer = 0 To bytes.Length - 1
hexn.Append(bytes(i).ToString("d"))
Next

return (hexn.ToString())

end function[/php]

[php] MsgBox(todecimal(TextBox1.Text))
[/php]
Thanks a lot, I never thought of it that way.

Solved.
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us