Getting unicode value for char in VB

How can I get unicode value for char?

For example, I know that I can do this with ascii:

i = Asc("a") // i == 97 (correct) 

What if I have a unicode char though?

 i = Asc("β€’") // i == 149 (incorrect... should return 8226) 

Obviously, the second example does not work, because this character is not in the Ascii set. Is there an equivalent function that I can use that will return 8226 instead of the wrong result 149 ?

I do this in Outlook 2003, if that matters.

+7
vba unicode
source share
2 answers

How about AscW ?

+16
source share

The answer is RC. They helped me a lot, but I had problems with the AscW() function, which sometimes returns negative values.

In my case, the problem arose when working with Chinese characters.

I found a job online:

 Function CharToUnicode(strChar As String) Dim lngUnicode As Long lngUnicode = AscW(strChar) If lngUnicode < 0 Then lngUnicode = 65536 + lngUnicode End If CharToUnicode = lngUnicode End Function 
+2
source share

All Articles