Ascii help

I have a form that has a cbobox that the user picks 1-254 to get ascii character. I would like to display in a lbl the ascii value that they chose.

I tried this....
lblComma.Text = Chr$(cboComma.text);

Yes I know this is vb code but I am very new to C# so I'm not sure what it would be for C#. I'm not having any luck in searches...evidently everyone knows this but me.

Guy

Comments

  • : I have a form that has a cbobox that the user picks 1-254 to get ascii character. I would like to display in a lbl the ascii value that they chose.
    :
    : I tried this....
    : lblComma.Text = Chr$(cboComma.text);
    :
    : Yes I know this is vb code but I am very new to C# so I'm not sure what it would be for C#. I'm not having any luck in searches...evidently everyone knows this but me.
    :
    : Guy
    :
    :

    There maybe a "sexier" way to do this but this is a way to do it.

    using System;
    using System.Text;

    .....

    string tempstr = cboComma.Text;
    byte[] er = new byte[] {(byte)(int.Parse(tempstr))};
    lblComma.Text = Encoding.ASCII.GetString(er);


    //Hope this works for you
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion