Getting the unicode value of a char in VB Getting the unicode value of a char in VB vba vba

Getting the unicode value of a char in VB


The answer provided by RC. helped me a lot but I had issues with the AscW() function sometimes returning negative values.

In my case the problem appeared when working with Chinese characters.

I found a work around on the web:

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


matomo