# Solved: VB.NET Converting from a character code to a string.



## osarius (Jul 24, 2010)

Hello,

I am trying to display a font in my program, but unfortunately one of the characters I need is exactly the same as the " character used in the coding. As I can't use literal coding in VB.NET, I need to know if there is a way to convert the hex character code (0x93) to ASCII so I can display it correctly.

Is there a way to do this, or is there a &xxx number I can use instead? I'm at a bit of a loss.

Thanks


----------



## ckphilli (Apr 29, 2006)

Got a code snippet? I'll try to help you out, but I need to get a grip on what you're doing.


----------



## osarius (Jul 24, 2010)

Not really - I can tell you what is happening though:

I am creating a program that people can use to draw out SimSig Simulation Layouts. It uses a special font, with symbols and icons, rather than letters, and it has some odd character codes.

I have buttons with the symbols on which the user clicks to insert the icon into a multiline textbox below. One of the symbols uses the same character as the quote (") mark in VB.NET, and as I can't use literal coding in VB.NET, I'm a little stuck. One thing I do know though, is the character code that Character Map has given me, which is 0x93. I was wondering if I can use a function in VB.NET that will convert that into the character at runtime. Perhaps something like Char(0x93)?


```
Private Sub cmdTCHOR_Click(sender As System.Object, e As System.EventArgs) Handles cmdTCHOR.Click
        Dim inserttext = "a"
        Dim insertPos As Integer = txtLayoutArea.SelectionStart
        txtLayoutArea.Text = txtLayoutArea.Text.Insert(insertPos, inserttext)
        txtLayoutArea.SelectionStart = insertPos + inserttext.Length
End Sub
```
Above is the code for one of the symbols. When the user clicks the button, the program inserts the symbol mapped by the letter 'a' into the textbox at the cursors current position.


----------



## ckphilli (Apr 29, 2006)

So theoretically, your objective is to make


```
Dim inserttext = """
```
work. (I know it doesn't, just making sure I understand)


----------



## osarius (Jul 24, 2010)

I have used FontForge and moved the symbol to another key, but yes, that is what I need.


----------



## ckphilli (Apr 29, 2006)

Ok, I'll try some stuff and see if I can help.


----------



## Ent (Apr 11, 2009)

Strings.Chr(34)
Will give the quote character.

To use an arbitrary character, look up the Ascii code in one of many tables, such as this one in the TSG library of knowledge.
http://library.techguy.org/wiki/ASCII


----------



## ckphilli (Apr 29, 2006)

Yup, just found that here: http://msdn.microsoft.com/en-us/library/267k4fw5.aspx


```
Private Sub InsertAscii()
   TextBox1.Text = "She said, " & Chr(34) & "You deserve a treat!" & Chr(34)
End Sub
```


----------



## osarius (Jul 24, 2010)

Ent, thanks! That worked - though not for the 0x93 code. I used FontForge to find the correct Alt code, which was 147 in this case!

Thank you ckphilli as well!


----------



## Ent (Apr 11, 2009)

Turns out you can use """" too. 
Thanks for that ckphilli.


----------



## ckphilli (Apr 29, 2006)

I always forget we have our own library and go straight to google...thanks for reminding me. Good stuff in there Ent.


----------

