Pregunta

I have some string data stored in a database which special characters are represented as Unicode Hexadecimal. I would like to convert the data.

Does anyone know how to do that in VBA without by replacing each special character.

e.g: The conversion I'm expecting is:

Opera\'e7\'e3o -> Operação

Thank you!

¿Fue útil?

Solución

Try this sample code:

Dim myStr
Dim nStart,nLen, sTmp
myStr = "Opera\'e7\'e3o"
nStart = 0
nLen = Len(myStr)

While nStart < nLen
    nStart = Instr(nStart+1,myStr,"\'")
    If nStart = 0 Then
        nStart = nLen
    Else
        sTmp = Mid(myStr,nStart,4)
        myStr = Replace(myStr,sTmp,Chr(CLng(Replace(sTmp,"\'","&h"))))
    End If
Wend
MsgBox myStr

Costis Papadakis

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top