Ascii help - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Ascii help

iwannagohomeiwannagohome Posts: 1Member
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

  • heileheile Posts: 7Member
    : 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.