Results 1 to 5 of 5

Thread: How can I get characters code?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2012
    Posts
    221

    How can I get characters code?

    Hello,

    I am trying to concat two strings at runtime and between them I want to insert a special character that I found in charmap in windows.

    There are many characters and their code is written in the down-left corner of the window.

    For example if I want to insert the diameter (Ø) character in a string that has U+00D8 how do I make this at runtime.

    Also I will have to check if this character exists or not in a textbox. (If textBox1.Text.Contains(......code???......) Then...)

    Thx.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I get characters code?

    The U+00D8 means a Unicode value of D8 in hexadecimal, which is 216 in decimal. The Convert.ToChar method will create a Char from an Integer containing its Unicode value, e.g.
    Code:
    Dim ch = Convert.ToChar(&HD8)
    You can then concatenate a Char with a String exactly as you would another String.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2012
    Posts
    221

    Re: How can I get characters code?

    Thank you. I got it.

    Cheers

  4. #4
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    311

    Re: How can I get characters code?

    Since it sounds like you may use this character often, you may consider creating a static variable so that wherever you you it, you can just use the static variable instead of having to keep using Covert.ToChar() function all over the place.

  5. #5
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: How can I get characters code?

    Is there any reason why Chr(&HD8) isn't adequate here?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width