Results 1 to 3 of 3
  1. #1
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired

    [Help]Converting Char to Decimal[Solved]

    For example if I input "a" into textbox1, it'll output "97" into textbox2.

    Any help?

  2. #2
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    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]
    Last edited by Blubb1337; 07-21-2010 at 09:29 PM.



  3. The Following User Says Thank You to Blubb1337 For This Useful Post:

    Lolland (07-22-2010)

  4. #3
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Thanks a lot, I never thought of it that way.

    Solved.

Similar Threads

  1. [help] making a text to hex converter and vice versa[Solved]
    By PixyStyx in forum Visual Basic Programming
    Replies: 5
    Last Post: 12-31-2010, 03:30 PM
  2. [Help]Convert VB6 code to VB.NET[Solved]
    By nathanael890 in forum Visual Basic Programming
    Replies: 13
    Last Post: 08-07-2010, 12:11 AM
  3. [Help]Convert decimal to Hex[Solved]
    By ppl2pass in forum Visual Basic Programming
    Replies: 3
    Last Post: 04-28-2010, 05:30 PM
  4. [help]Convert String to Color[Solved]
    By mnpeepno2 in forum Visual Basic Programming
    Replies: 10
    Last Post: 04-02-2010, 01:08 PM
  5. [Help]Convert CE Script to VB
    By jeffrey1 in forum Visual Basic Programming
    Replies: 2
    Last Post: 10-29-2009, 03:54 PM