How to get a ASCII value for a set of text?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hellboss
    New Member
    • Jun 2007
    • 50

    How to get a ASCII value for a set of text?

    Hi ! im working with asp.net(vb)
    I need to get the ASCII value for a set of text which is typed in a text box.
    I use a text box and a button, clicking on the button should show the equivalent ascii value for the text which is typed in the text box.
    How do i achieve this?

    Please provide a valid solution. Thanks in advance.
    Last edited by hellboss; Jan 22 '08, 09:31 AM. Reason: Modification in context
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You are referering to the decimal value for the individual characters in a string right?
    Code:
    char c= 'A';
    int asciivalue=(int)c;
    //now asciivalue is = to 65
    Then remember you can do something like this:
    Code:
    string mystr="Fred runs fast.";
    for(int i=0;i<mystr.Length;i++)
    {
       char c=mystr[i];
       int asciivalue=(int)c;
       //now do something with the ascii value
    }

    Comment

    • trynt799799
      New Member
      • Jan 2008
      • 8

      #3
      Use the the
      Code:
      System.Convert.ToInt16
      method

      Comment

      Working...