Thứ Sáu, 1 tháng 4, 2016

VBA Excel - Hàm chuyển đổi mã font

Public Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxW" (ByVal hwnd As Long, _
ByVal lpText As Long, _
ByVal lpCaption As Long, _
ByVal wType As Long) As Long
Public Function MsgUni(ByVal Chuoi As String, Optional Bieutuong As VbMsgBoxStyle = 64, _
Optional ByVal Tieude As String = "Tho6ng ba1o !", _
Optional ByVal Khac As Long = 0) As VbMsgBoxResult

MsgUni = MessageBox(Khac, StrPtr(UniVBA(Chuoi)), StrPtr(UniVBA(Tieude)), Bieutuong)
End Function

Public Function UniVBA(Str As String) As String
Dim Ma As String, MaLuu As String, i As Long, a As Long
a = 1
For i = a To Len(Str)
i = a
Ma = Mid(Str, i, 3)
MaLuu = Ma
Select Case Ma
Case "a81": Ma = ChrW(7855): Case "A81": Ma = ChrW(7854)
Case "a82": Ma = ChrW(7857): Case "A82": Ma = ChrW(7856)
Case "a83": Ma = ChrW(7859): Case "A83": Ma = ChrW(7858)
Case "a84": Ma = ChrW(7861): Case "A84": Ma = ChrW(7860)
Case "a85": Ma = ChrW(7863): Case "A85": Ma = ChrW(7862)
Case "a61": Ma = ChrW(7845): Case "A61": Ma = ChrW(7844)
Case "a62": Ma = ChrW(7847): Case "A62": Ma = ChrW(7846)
Case "a63": Ma = ChrW(7849): Case "A63": Ma = ChrW(7848)
Case "a64": Ma = ChrW(7851): Case "A64": Ma = ChrW(7850)
Case "a65": Ma = ChrW(7853): Case "A65": Ma = ChrW(7852)
Case "e61": Ma = ChrW(7871): Case "E61": Ma = ChrW(7870)
Case "e62": Ma = ChrW(7873): Case "E62": Ma = ChrW(7872)
Case "e63": Ma = ChrW(7875): Case "E63": Ma = ChrW(7874)
Case "e64": Ma = ChrW(7877): Case "E64": Ma = ChrW(7876)
Case "e65": Ma = ChrW(7879): Case "E65": Ma = ChrW(7878)
Case "o61": Ma = ChrW(7889): Case "O61": Ma = ChrW(7888)
Case "o62": Ma = ChrW(7891): Case "O62": Ma = ChrW(7890)
Case "o63": Ma = ChrW(7893): Case "O63": Ma = ChrW(7892)
Case "o64": Ma = ChrW(7895): Case "O64": Ma = ChrW(7894)
Case "o65": Ma = ChrW(7897): Case "O65": Ma = ChrW(7896)
Case "o71": Ma = ChrW(7899): Case "O71": Ma = ChrW(7898)
Case "o72": Ma = ChrW(7901): Case "O72": Ma = ChrW(7900)
Case "o73": Ma = ChrW(7903): Case "O73": Ma = ChrW(7902)
Case "o74": Ma = ChrW(7905): Case "O74": Ma = ChrW(7904)
Case "o75": Ma = ChrW(7907): Case "O75": Ma = ChrW(7906)
Case "u71": Ma = ChrW(7913): Case "U71": Ma = ChrW(7912)
Case "u72": Ma = ChrW(7915): Case "U72": Ma = ChrW(7914)
Case "u73": Ma = ChrW(7917): Case "U73": Ma = ChrW(7916)
Case "u74": Ma = ChrW(7919): Case "U74": Ma = ChrW(7918)
Case "u75": Ma = ChrW(7921): Case "U75": Ma = ChrW(7920)
End Select
If Ma <> MaLuu Then
UniVBA = UniVBA & Ma
a = i + 3
Else
Ma = Mid(Str, i, 2)
MaLuu = Ma
Select Case Ma
Case "a1": Ma = ChrW(225): Case "A1": Ma = ChrW(193)
Case "a2": Ma = ChrW(224): Case "A2": Ma = ChrW(192)
Case "a3": Ma = ChrW(7843): Case "A3": Ma = ChrW(7842)
Case "a4": Ma = ChrW(227): Case "A4": Ma = ChrW(195)
Case "a5": Ma = ChrW(7841): Case "A5": Ma = ChrW(7840)
Case "a8": Ma = ChrW(259): Case "A8": Ma = ChrW(258)
Case "a6": Ma = ChrW(226): Case "A6": Ma = ChrW(194)
Case "d9": Ma = ChrW(273): Case "D9": Ma = ChrW(272)
Case "e1": Ma = ChrW(233): Case "E1": Ma = ChrW(201)
Case "e2": Ma = ChrW(232): Case "E2": Ma = ChrW(200)
Case "e3": Ma = ChrW(7867): Case "E3": Ma = ChrW(7866)
Case "e4": Ma = ChrW(7869): Case "E4": Ma = ChrW(7868)
Case "e5": Ma = ChrW(7865): Case "E5": Ma = ChrW(7864)
Case "e6": Ma = ChrW(234): Case "E6": Ma = ChrW(202)
Case "i1": Ma = ChrW(237): Case "I1": Ma = ChrW(205)
Case "i2": Ma = ChrW(236): Case "I2": Ma = ChrW(204)
Case "i3": Ma = ChrW(7881): Case "I3": Ma = ChrW(7880)
Case "i4": Ma = ChrW(297): Case "I4": Ma = ChrW(296)
Case "i5": Ma = ChrW(7883): Case "I5": Ma = ChrW(7882)
Case "o1": Ma = ChrW(243): Case "O1": Ma = ChrW(211)
Case "o2": Ma = ChrW(242): Case "O2": Ma = ChrW(210)
Case "o3": Ma = ChrW(7887): Case "O3": Ma = ChrW(7886)
Case "o4": Ma = ChrW(245): Case "O4": Ma = ChrW(213)
Case "o5": Ma = ChrW(7885): Case "O5": Ma = ChrW(7884)
Case "o6": Ma = ChrW(244): Case "O6": Ma = ChrW(212)
Case "o7": Ma = ChrW(417): Case "O7": Ma = ChrW(416)
Case "u1": Ma = ChrW(250): Case "U1": Ma = ChrW(218)
Case "u2": Ma = ChrW(249): Case "U2": Ma = ChrW(217)
Case "u3": Ma = ChrW(7911): Case "U3": Ma = ChrW(7910)
Case "u4": Ma = ChrW(361): Case "U4": Ma = ChrW(360)
Case "u5": Ma = ChrW(7909): Case "U5": Ma = ChrW(7908)
Case "u7": Ma = ChrW(432): Case "U7": Ma = ChrW(431)
Case "y1": Ma = ChrW(253): Case "Y1": Ma = ChrW(221)
Case "y2": Ma = ChrW(7923): Case "Y2": Ma = ChrW(7922)
Case "y3": Ma = ChrW(7927): Case "Y3": Ma = ChrW(7926)
Case "y4": Ma = ChrW(7929): Case "Y4": Ma = ChrW(7928)
Case "y5": Ma = ChrW(7925): Case "Y5": Ma = ChrW(7924)
End Select
If Ma <> MaLuu Then
UniVBA = UniVBA & Ma
a = i + 2
Else
UniVBA = UniVBA & Mid(Str, i, 1)
a = i + 1
End If
End If
Next i
End Function

'==================================

'Function suu tam tu caulacbovb.com
Public Function Uni(sText As String)
Dim i As Integer, J As Integer
Dim sCurChar As String, sPreChar As String, sPreTxt As String
For J = 1 To 2
For i = 2 To Len(sText)
sCurChar = Mid(sText, i, 1)
sPreTxt = Left(sText, i - 2)
sPreChar = Mid(sText, i - 1, 1)
Select Case sCurChar
Case "1"
Select Case sPreChar
'a
Case "a": sText = sPreTxt & ChrW$(&HE1) & Right(sText, Len(sText) - i)
Case "A": sText = sPreTxt & ChrW$(&HC1) & Right(sText, Len(sText) - i)
Case ChrW$(&HE2): sText = sPreTxt & ChrW$(&H1EA5) & Right(sText, Len(sText) - i)
Case ChrW$(&HC2): sText = sPreTxt & ChrW$(&H1EA4) & Right(sText, Len(sText) - i)
Case ChrW$(&H103): sText = sPreTxt & ChrW$(&H1EAF) & Right(sText, Len(sText) - i)
Case ChrW$(&H102): sText = sPreTxt & ChrW$(&H1EAE) & Right(sText, Len(sText) - i)

'e
Case "e": sText = sPreTxt & ChrW$(&HE9) & Right(sText, Len(sText) - i)
Case "E": sText = sPreTxt & ChrW$(&HC9) & Right(sText, Len(sText) - i)
Case ChrW$(&HEA): sText = sPreTxt & ChrW$(&H1EBF) & Right(sText, Len(sText) - i)
Case ChrW$(&HCA): sText = sPreTxt & ChrW$(&H1EBE) & Right(sText, Len(sText) - i)

'i
Case "i": sText = sPreTxt & ChrW$(&HED) & Right(sText, Len(sText) - i)
Case "I": sText = sPreTxt & ChrW$(&HCD) & Right(sText, Len(sText) - i)

'o
Case "o": sText = sPreTxt & ChrW$(&HF3) & Right(sText, Len(sText) - i)
Case "O": sText = sPreTxt & ChrW$(&HD3) & Right(sText, Len(sText) - i)
Case ChrW$(&HF4): sText = sPreTxt & ChrW$(&H1ED1) & Right(sText, Len(sText) - i)
Case ChrW$(&HD4): sText = sPreTxt & ChrW$(&H1ED0) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A1): sText = sPreTxt & ChrW$(&H1EDB) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A0): sText = sPreTxt & ChrW$(&H1EDA) & Right(sText, Len(sText) - i)

'u
Case "u": sText = sPreTxt & ChrW$(&HFA) & Right(sText, Len(sText) - i)
Case "U": sText = sPreTxt & ChrW$(&HDA) & Right(sText, Len(sText) - i)
Case ChrW$(&H1B0): sText = sPreTxt & ChrW$(&H1EE9) & Right(sText, Len(sText) - i)
Case ChrW$(&H1AF): sText = sPreTxt & ChrW$(&H1EE8) & Right(sText, Len(sText) - i)

'y
Case "y": sText = sPreTxt & ChrW$(&HFD) & Right(sText, Len(sText) - i)
Case "Y": sText = sPreTxt & ChrW$(&HDD) & Right(sText, Len(sText) - i)

End Select

Case "2"
Select Case sPreChar
'a
Case "a": sText = sPreTxt & ChrW$(&HE0) & Right(sText, Len(sText) - i)
Case "A": sText = sPreTxt & ChrW$(&HC0) & Right(sText, Len(sText) - i)
Case ChrW$(&HE2): sText = sPreTxt & ChrW$(&H1EA7) & Right(sText, Len(sText) - i)
Case ChrW$(&HC2): sText = sPreTxt & ChrW$(&H1EA6) & Right(sText, Len(sText) - i)
Case ChrW$(&H103): sText = sPreTxt & ChrW$(&H1EB1) & Right(sText, Len(sText) - i)
Case ChrW$(&H102): sText = sPreTxt & ChrW$(&H1EB0) & Right(sText, Len(sText) - i)

'e
Case "e": sText = sPreTxt & ChrW$(&HE8) & Right(sText, Len(sText) - i)
Case "E": sText = sPreTxt & ChrW$(&HC8) & Right(sText, Len(sText) - i)
Case ChrW$(&HEA): sText = sPreTxt & ChrW$(&H1EC1) & Right(sText, Len(sText) - i)
Case ChrW$(&HCA): sText = sPreTxt & ChrW$(&H1EC0) & Right(sText, Len(sText) - i)

'i
Case "i": sText = sPreTxt & ChrW$(&HEC) & Right(sText, Len(sText) - i)
Case "I": sText = sPreTxt & ChrW$(&HCC) & Right(sText, Len(sText) - i)

'o
Case "o": sText = sPreTxt & ChrW$(&HF2) & Right(sText, Len(sText) - i)
Case "O": sText = sPreTxt & ChrW$(&HD2) & Right(sText, Len(sText) - i)
Case ChrW$(&HF4): sText = sPreTxt & ChrW$(&H1ED3) & Right(sText, Len(sText) - i)
Case ChrW$(&HD4): sText = sPreTxt & ChrW$(&H1ED2) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A1): sText = sPreTxt & ChrW$(&H1EDD) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A0): sText = sPreTxt & ChrW$(&H1EDC) & Right(sText, Len(sText) - i)

'u
Case "u": sText = sPreTxt & ChrW$(&HF9) & Right(sText, Len(sText) - i)
Case "U": sText = sPreTxt & ChrW$(&HD9) & Right(sText, Len(sText) - i)
Case ChrW$(&H1B0): sText = sPreTxt & ChrW$(&H1EEB) & Right(sText, Len(sText) - i)
Case ChrW$(&H1AF): sText = sPreTxt & ChrW$(&H1EEA) & Right(sText, Len(sText) - i)

'y
Case "y": sText = sPreTxt & ChrW$(&H1EF3) & Right(sText, Len(sText) - i)
Case "Y": sText = sPreTxt & ChrW$(&H1EF2) & Right(sText, Len(sText) - i)

End Select

Case "3"
Select Case sPreChar
'a
Case "a": sText = sPreTxt & ChrW$(&H1EA3) & Right(sText, Len(sText) - i)
Case "A": sText = sPreTxt & ChrW$(&H1EA2) & Right(sText, Len(sText) - i)
Case ChrW$(&HE2): sText = sPreTxt & ChrW$(&H1EA9) & Right(sText, Len(sText) - i)
Case ChrW$(&HC2): sText = sPreTxt & ChrW$(&H1EA8) & Right(sText, Len(sText) - i)
Case ChrW$(&H103): sText = sPreTxt & ChrW$(&H1EB3) & Right(sText, Len(sText) - i)
Case ChrW$(&H102): sText = sPreTxt & ChrW$(&H1EB2) & Right(sText, Len(sText) - i)

'e
Case "e": sText = sPreTxt & ChrW$(&H1EBB) & Right(sText, Len(sText) - i)
Case "E": sText = sPreTxt & ChrW$(&H1EBA) & Right(sText, Len(sText) - i)
Case ChrW$(&HEA): sText = sPreTxt & ChrW$(&H1EC3) & Right(sText, Len(sText) - i)
Case ChrW$(&HCA): sText = sPreTxt & ChrW$(&H1EC2) & Right(sText, Len(sText) - i)

'i
Case "i": sText = sPreTxt & ChrW$(&H1EC9) & Right(sText, Len(sText) - i)
Case "I": sText = sPreTxt & ChrW$(&H1EC8) & Right(sText, Len(sText) - i)

'o
Case "o": sText = sPreTxt & ChrW$(&H1ECF) & Right(sText, Len(sText) - i)
Case "O": sText = sPreTxt & ChrW$(&H1ECE) & Right(sText, Len(sText) - i)
Case ChrW$(&HF4): sText = sPreTxt & ChrW$(&H1ED5) & Right(sText, Len(sText) - i)
Case ChrW$(&HD4): sText = sPreTxt & ChrW$(&H1ED4) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A1): sText = sPreTxt & ChrW$(&H1EDF) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A0): sText = sPreTxt & ChrW$(&H1EDE) & Right(sText, Len(sText) - i)

'u
Case "u": sText = sPreTxt & ChrW$(&H1EE7) & Right(sText, Len(sText) - i)
Case "U": sText = sPreTxt & ChrW$(&H1EE6) & Right(sText, Len(sText) - i)
Case ChrW$(&H1B0): sText = sPreTxt & ChrW$(&H1EED) & Right(sText, Len(sText) - i)
Case ChrW$(&H1AF): sText = sPreTxt & ChrW$(&H1EEC) & Right(sText, Len(sText) - i)

'y
Case "y": sText = sPreTxt & ChrW$(&H1EF7) & Right(sText, Len(sText) - i)
Case "Y": sText = sPreTxt & ChrW$(&H1EF6) & Right(sText, Len(sText) - i)

End Select

Case "4"
Select Case sPreChar
'a
Case "a": sText = sPreTxt & ChrW$(&HE3) & Right(sText, Len(sText) - i)
Case "A": sText = sPreTxt & ChrW$(&HC3) & Right(sText, Len(sText) - i)
Case ChrW$(&HE2): sText = sPreTxt & ChrW$(&H1EAB) & Right(sText, Len(sText) - i)
Case ChrW$(&HC2): sText = sPreTxt & ChrW$(&H1EAA) & Right(sText, Len(sText) - i)
Case ChrW$(&H103): sText = sPreTxt & ChrW$(&H1EB5) & Right(sText, Len(sText) - i)
Case ChrW$(&H102): sText = sPreTxt & ChrW$(&H1EB4) & Right(sText, Len(sText) - i)

'e
Case "e": sText = sPreTxt & ChrW$(&H1EBD) & Right(sText, Len(sText) - i)
Case "E": sText = sPreTxt & ChrW$(&H1EBC) & Right(sText, Len(sText) - i)
Case ChrW$(&HEA): sText = sPreTxt & ChrW$(&H1EC5) & Right(sText, Len(sText) - i)
Case ChrW$(&HCA): sText = sPreTxt & ChrW$(&H1EC4) & Right(sText, Len(sText) - i)

'i
Case "i": sText = sPreTxt & ChrW$(&H129) & Right(sText, Len(sText) - i)
Case "I": sText = sPreTxt & ChrW$(&H128) & Right(sText, Len(sText) - i)

'o
Case "o": sText = sPreTxt & ChrW$(&HF5) & Right(sText, Len(sText) - i)
Case "O": sText = sPreTxt & ChrW$(&HD5) & Right(sText, Len(sText) - i)
Case ChrW$(&HF4): sText = sPreTxt & ChrW$(&H1ED7) & Right(sText, Len(sText) - i)
Case ChrW$(&HD4): sText = sPreTxt & ChrW$(&H1ED6) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A1): sText = sPreTxt & ChrW$(&H1EE1) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A0): sText = sPreTxt & ChrW$(&H1EE0) & Right(sText, Len(sText) - i)

'u
Case "u": sText = sPreTxt & ChrW$(&H169) & Right(sText, Len(sText) - i)
Case "U": sText = sPreTxt & ChrW$(&H168) & Right(sText, Len(sText) - i)
Case ChrW$(&H1B0): sText = sPreTxt & ChrW$(&H1EEF) & Right(sText, Len(sText) - i)
Case ChrW$(&H1AF): sText = sPreTxt & ChrW$(&H1EEE) & Right(sText, Len(sText) - i)

'y
Case "y": sText = sPreTxt & ChrW$(&H1EF9) & Right(sText, Len(sText) - i)
Case "Y": sText = sPreTxt & ChrW$(&H1EF8) & Right(sText, Len(sText) - i)
End Select

Case "5"
Select Case sPreChar
'a
Case "a": sText = sPreTxt & ChrW$(&H1EA1) & Right(sText, Len(sText) - i)
Case "A": sText = sPreTxt & ChrW$(&H1EA0) & Right(sText, Len(sText) - i)
Case ChrW$(&HE2): sText = sPreTxt & ChrW$(&H1EAD) & Right(sText, Len(sText) - i)
Case ChrW$(&HC2): sText = sPreTxt & ChrW$(&H1EAC) & Right(sText, Len(sText) - i)
Case ChrW$(&H103): sText = sPreTxt & ChrW$(&H1EB7) & Right(sText, Len(sText) - i)
Case ChrW$(&H102): sText = sPreTxt & ChrW$(&H1EB6) & Right(sText, Len(sText) - i)

'e
Case "e": sText = sPreTxt & ChrW$(&H1EB9) & Right(sText, Len(sText) - i)
Case "E": sText = sPreTxt & ChrW$(&H1EB8) & Right(sText, Len(sText) - i)
Case ChrW$(&HEA): sText = sPreTxt & ChrW$(&H1EC7) & Right(sText, Len(sText) - i)
Case ChrW$(&HCA): sText = sPreTxt & ChrW$(&H1EC6) & Right(sText, Len(sText) - i)

'i
Case "i": sText = sPreTxt & ChrW$(&H1ECB) & Right(sText, Len(sText) - i)
Case "I": sText = sPreTxt & ChrW$(&H1ECA) & Right(sText, Len(sText) - i)

'o
Case "o": sText = sPreTxt & ChrW$(&H1ECD) & Right(sText, Len(sText) - i)
Case "O": sText = sPreTxt & ChrW$(&H1ECC) & Right(sText, Len(sText) - i)
Case ChrW$(&HF4): sText = sPreTxt & ChrW$(&H1ED9) & Right(sText, Len(sText) - i)
Case ChrW$(&HD4): sText = sPreTxt & ChrW$(&H1ED8) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A1): sText = sPreTxt & ChrW$(&H1EE3) & Right(sText, Len(sText) - i)
Case ChrW$(&H1A0): sText = sPreTxt & ChrW$(&H1EE2) & Right(sText, Len(sText) - i)

'u
Case "u": sText = sPreTxt & ChrW$(&H1EE5) & Right(sText, Len(sText) - i)
Case "U": sText = sPreTxt & ChrW$(&H1EE4) & Right(sText, Len(sText) - i)
Case ChrW$(&H1B0): sText = sPreTxt & ChrW$(&H1EF1) & Right(sText, Len(sText) - i)
Case ChrW$(&H1AF): sText = sPreTxt & ChrW$(&H1EF0) & Right(sText, Len(sText) - i)

'y
Case "y": sText = sPreTxt & ChrW$(&H1EF5) & Right(sText, Len(sText) - i)
Case "Y": sText = sPreTxt & ChrW$(&H1EF4) & Right(sText, Len(sText) - i)
End Select

Case "6"
Select Case sPreChar
'a
Case "a": sText = sPreTxt & ChrW$(&HE2) & Right(sText, Len(sText) - i)
Case "A": sText = sPreTxt & ChrW$(&HC2) & Right(sText, Len(sText) - i)

'e
Case "e": sText = sPreTxt & ChrW$(&HEA) & Right(sText, Len(sText) - i)
Case "E": sText = sPreTxt & ChrW$(&HCA) & Right(sText, Len(sText) - i)

'o
Case "o": sText = sPreTxt & ChrW$(&HF4) & Right(sText, Len(sText) - i)
Case "O": sText = sPreTxt & ChrW$(&HD4) & Right(sText, Len(sText) - i)
End Select

Case "7"
Select Case sPreChar
'o
Case "o": sText = sPreTxt & ChrW$(&H1A1) & Right(sText, Len(sText) - i)
Case "O": sText = sPreTxt & ChrW$(&H1A0) & Right(sText, Len(sText) - i)

'u
Case "u": sText = sPreTxt & ChrW$(&H1B0) & Right(sText, Len(sText) - i)
Case "U": sText = sPreTxt & ChrW$(&H1AF) & Right(sText, Len(sText) - i)
End Select

Case "8"
Select Case sPreChar
'a
Case "a": sText = sPreTxt & ChrW$(&H103) & Right(sText, Len(sText) - i)
Case "A": sText = sPreTxt & ChrW$(&H102) & Right(sText, Len(sText) - i)
End Select

Case "9"
Select Case sPreChar
'd
Case "d": sText = sPreTxt & ChrW$(&H111) & Right(sText, Len(sText) - i)
Case "D": sText = sPreTxt & ChrW$(&H110) & Right(sText, Len(sText) - i)
End Select

End Select
Next i
Next J
Uni = sText
End Function

Option Explicit
Function TCVN3toVNI(vnstr As String)
Dim c As String, i As Long
For i = 1 To Len(vnstr)
c = Mid(vnstr, i, 1)
Select Case c
Case "a": c = "a"
Case "¸": c = "aù"
Case "µ": c = "aø"
Case "¶": c = "aû"
Case "·": c = "aõ"
Case "¹": c = "aï"
Case "¨": c = "aê"
Case "¾": c = "aé"
Case "»": c = "aè"
Case "¼": c = "aú"
Case "½": c = "aü"
Case "Æ": c = "aë"
Case "©": c = "aâ"
Case "Ê": c = "aá"
Case "Ç": c = "aà"
Case "È": c = "aå"
Case "É": c = "aã"
Case "Ë": c = "aä"
Case "e": c = "e"
Case "Ð": c = "eù"
Case "Ì": c = "eø"
Case "Î": c = "eû"
Case "Ï": c = "eõ"
Case "Ñ": c = "eï"
Case "ª": c = "eâ"
Case "Õ": c = "eá"
Case "Ò": c = "eà"
Case "Ó": c = "eå"
Case "Ô": c = "eã"
Case "Ö": c = "eä"
Case "o": c = "o"
Case "ã": c = "où"
Case "ß": c = "oø"
Case "á": c = "oû"
Case "â": c = "oõ"
Case "ä": c = "oï"
Case "«": c = "oâ"
Case "è": c = "oá"
Case "å": c = "oà"
Case "æ": c = "oå"
Case "ç": c = "oã"
Case "é": c = "oä"
Case "¬": c = "ô"
Case "í": c = "ôù"
Case "ê": c = "ôø"
Case "ë": c = "ôû"
Case "ì": c = "ôõ"
Case "î": c = "ôï"
Case "i": c = "i"
Case "Ý": c = "í"
Case "×": c = "ì"
Case "Ø": c = "æ"
Case "Ü": c = "ó"
Case "Þ": c = "ò"
Case "u": c = "u"
Case "ó": c = "uù"
Case "ï": c = "uø"
Case "ñ": c = "uû"
Case "ò": c = "uõ"
Case "ô": c = "uï"
Case "­": c = "ö"
Case "ø": c = "öù"
Case "õ": c = "uø"
Case "ö": c = "öû"
Case "÷": c = "öõ"
Case "ù": c = "öï"
Case "y": c = "y"
Case "ý": c = "yù"
Case "ú": c = "yø"
Case "û": c = "yû"
Case "ü": c = "yõ"
Case "þ": c = "î"
Case "®": c = "ñ"
Case "A": c = "A"
Case "¡": c = "AÊ"
Case "¢": c = "AÂ"
Case "E": c = "E"
Case "£": c = "EÂ"
Case "O": c = "O"
Case "¤": c = "OÂ"
Case "¥": c = "Ô"
Case "I": c = "I"
Case "U": c = "U"
Case "¦": c = "Ö"
Case "Y": c = "Y"
Case "§": c = "Ñ"
End Select
TCVN3toVNI = TCVN3toVNI + c
Next i
End Function
Function TCVN3toUNICODE(vnstr As String)
Dim c As String, i As Long
For i = 1 To Len(vnstr)
c = Mid(vnstr, i, 1)
Select Case c
Case "a": c = ChrW$(97)
Case "¸": c = ChrW$(225)
Case "µ": c = ChrW$(224)
Case "¶": c = ChrW$(7843)
Case "·": c = ChrW$(227)
Case "¹": c = ChrW$(7841)
Case "¨": c = ChrW$(259)
Case "¾": c = ChrW$(7855)
Case "»": c = ChrW$(7857)
Case "¼": c = ChrW$(7859)
Case "½": c = ChrW$(7861)
Case "Æ": c = ChrW$(7863)
Case "©": c = ChrW$(226)
Case "Ê": c = ChrW$(7845)
Case "Ç": c = ChrW$(7847)
Case "È": c = ChrW$(7849)
Case "É": c = ChrW$(7851)
Case "Ë": c = ChrW$(7853)
Case "e": c = ChrW$(101)
Case "Ð": c = ChrW$(233)
Case "Ì": c = ChrW$(232)
Case "Î": c = ChrW$(7867)
Case "Ï": c = ChrW$(7869)
Case "Ñ": c = ChrW$(7865)
Case "ª": c = ChrW$(234)
Case "Õ": c = ChrW$(7871)
Case "Ò": c = ChrW$(7873)
Case "Ó": c = ChrW$(7875)
Case "Ô": c = ChrW$(7877)
Case "Ö": c = ChrW$(7879)
Case "o": c = ChrW$(111)
Case "ã": c = ChrW$(243)
Case "ß": c = ChrW$(242)
Case "á": c = ChrW$(7887)
Case "â": c = ChrW$(245)
Case "ä": c = ChrW$(7885)
Case "«": c = ChrW$(244)
Case "è": c = ChrW$(7889)
Case "å": c = ChrW$(7891)
Case "æ": c = ChrW$(7893)
Case "ç": c = ChrW$(7895)
Case "é": c = ChrW$(7897)
Case "¬": c = ChrW$(417)
Case "í": c = ChrW$(7899)
Case "ê": c = ChrW$(7901)
Case "ë": c = ChrW$(7903)
Case "ì": c = ChrW$(7905)
Case "î": c = ChrW$(7907)
Case "i": c = ChrW$(105)
Case "Ý": c = ChrW$(237)
Case "×": c = ChrW$(236)
Case "Ø": c = ChrW$(7881)
Case "Ü": c = ChrW$(297)
Case "Þ": c = ChrW$(7883)
Case "u": c = ChrW$(117)
Case "ó": c = ChrW$(250)
Case "ï": c = ChrW$(249)
Case "ñ": c = ChrW$(7911)
Case "ò": c = ChrW$(361)
Case "ô": c = ChrW$(7909)
Case "­": c = ChrW$(432)
Case "ø": c = ChrW$(7913)
Case "õ": c = ChrW$(7915)
Case "ö": c = ChrW$(7917)
Case "÷": c = ChrW$(7919)
Case "ù": c = ChrW$(7921)
Case "y": c = ChrW$(121)
Case "ý": c = ChrW$(253)
Case "ú": c = ChrW$(7923)
Case "û": c = ChrW$(7927)
Case "ü": c = ChrW$(7929)
Case "þ": c = ChrW$(7925)
Case "®": c = ChrW$(273)
Case "A": c = ChrW$(65)
Case "¡": c = ChrW$(258)
Case "¢": c = ChrW$(194)
Case "E": c = ChrW$(69)
Case "£": c = ChrW$(202)
Case "O": c = ChrW$(79)
Case "¤": c = ChrW$(212)
Case "¥": c = ChrW$(416)
Case "I": c = ChrW$(73)
Case "U": c = ChrW$(85)
Case "¦": c = ChrW$(431)
Case "Y": c = ChrW$(89)
Case "§": c = ChrW$(272)
End Select
TCVN3toUNICODE = TCVN3toUNICODE + c
Next i
End Function
Function UNICODEtoTCVN3(vnstr As String)
Dim c As String, i As Long
For i = 1 To Len(vnstr)
c = Mid(vnstr, i, 1)
Select Case c
Case ChrW$(97): c = "a"
Case ChrW$(225): c = "¸"
Case ChrW$(224): c = "µ"
Case ChrW$(7843): c = "¶"
Case ChrW$(227): c = "·"
Case ChrW$(7841): c = "¹"
Case ChrW$(259): c = "¨"
Case ChrW$(7855): c = "¾"
Case ChrW$(7857): c = "»"
Case ChrW$(7859): c = "¼"
Case ChrW$(7861): c = "½"
Case ChrW$(7863): c = "Æ"
Case ChrW$(226): c = "©"
Case ChrW$(7845): c = "Ê"
Case ChrW$(7847): c = "Ç"
Case ChrW$(7849): c = "È"
Case ChrW$(7851): c = "É"
Case ChrW$(7853): c = "Ë"
Case ChrW$(101): c = "e"
Case ChrW$(233): c = "Ð"
Case ChrW$(232): c = "Ì"
Case ChrW$(7867): c = "Î"
Case ChrW$(7869): c = "Ï"
Case ChrW$(7865): c = "Ñ"
Case ChrW$(234): c = "ª"
Case ChrW$(7871): c = "Õ"
Case ChrW$(7873): c = "Ò"
Case ChrW$(7875): c = "Ó"
Case ChrW$(7877): c = "Ô"
Case ChrW$(7879): c = "Ö"
Case ChrW$(111): c = "o"
Case ChrW$(243): c = "ã"
Case ChrW$(242): c = "ß"
Case ChrW$(7887): c = "á"
Case ChrW$(245): c = "â"
Case ChrW$(7885): c = "ä"
Case ChrW$(244): c = "«"
Case ChrW$(7889): c = "è"
Case ChrW$(7891): c = "å"
Case ChrW$(7893): c = "æ"
Case ChrW$(7895): c = "ç"
Case ChrW$(7897): c = "é"
Case ChrW$(417): c = "¬"
Case ChrW$(7899): c = "í"
Case ChrW$(7901): c = "ê"
Case ChrW$(7903): c = "ë"
Case ChrW$(7905): c = "ì"
Case ChrW$(7907): c = "î"
Case ChrW$(105): c = "i"
Case ChrW$(237): c = "Ý"
Case ChrW$(236): c = "×"
Case ChrW$(7881): c = "Ø"
Case ChrW$(297): c = "Ü"
Case ChrW$(7883): c = "Þ"
Case ChrW$(117): c = "u"
Case ChrW$(250): c = "ó"
Case ChrW$(249): c = "ï"
Case ChrW$(7911): c = "ñ"
Case ChrW$(361): c = "ò"
Case ChrW$(7909): c = "ô"
Case ChrW$(432): c = "­"
Case ChrW$(7913): c = "ø"
Case ChrW$(7915): c = "õ"
Case ChrW$(7917): c = "ö"
Case ChrW$(7919): c = "÷"
Case ChrW$(7921): c = "ù"
Case ChrW$(121): c = "y"
Case ChrW$(253): c = "ý"
Case ChrW$(7923): c = "ú"
Case ChrW$(7927): c = "û"
Case ChrW$(7929): c = "ü"
Case ChrW$(7925): c = "þ"
Case ChrW$(273): c = "®"
Case ChrW$(65): c = "A"
Case ChrW$(193): c = "¸"
Case ChrW$(192): c = "µ"
Case ChrW$(7842): c = "¶"
Case ChrW$(195): c = "·"
Case ChrW$(7840): c = "¹"
Case ChrW$(258): c = "¡"
Case ChrW$(7854): c = "¾"
Case ChrW$(7856): c = "»"
Case ChrW$(7858): c = "¼"
Case ChrW$(7860): c = "½"
Case ChrW$(7862): c = "Æ"
Case ChrW$(194): c = "¢"
Case ChrW$(7844): c = "Ê"
Case ChrW$(7846): c = "Ç"
Case ChrW$(7848): c = "È"
Case ChrW$(7850): c = "É"
Case ChrW$(7852): c = "Ë"
Case ChrW$(69): c = "E"
Case ChrW$(201): c = "Ð"
Case ChrW$(200): c = "Ì"
Case ChrW$(7866): c = "Î"
Case ChrW$(7868): c = "Ï"
Case ChrW$(7864): c = "Ñ"
Case ChrW$(202): c = "£"
Case ChrW$(7870): c = "Õ"
Case ChrW$(7872): c = "Ò"
Case ChrW$(7874): c = "Ó"
Case ChrW$(7876): c = "Ô"
Case ChrW$(7878): c = "Ö"
Case ChrW$(79): c = "O"
Case ChrW$(211): c = "ã"
Case ChrW$(210): c = "ß"
Case ChrW$(7886): c = "á"
Case ChrW$(213): c = "â"
Case ChrW$(7884): c = "ä"
Case ChrW$(212): c = "¤"
Case ChrW$(7888): c = "è"
Case ChrW$(7890): c = "å"
Case ChrW$(7892): c = "æ"
Case ChrW$(7894): c = "ç"
Case ChrW$(7896): c = "é"
Case ChrW$(416): c = "¥"
Case ChrW$(7898): c = "í"
Case ChrW$(7900): c = "ê"
Case ChrW$(7902): c = "ë"
Case ChrW$(7904): c = "ì"
Case ChrW$(7906): c = "î"
Case ChrW$(73): c = "I"
Case ChrW$(205): c = "Ý"
Case ChrW$(204): c = "×"
Case ChrW$(7880): c = "Ø"
Case ChrW$(296): c = "Ü"
Case ChrW$(7882): c = "Þ"
Case ChrW$(85): c = "U"
Case ChrW$(218): c = "ó"
Case ChrW$(217): c = "ï"
Case ChrW$(7910): c = "ñ"
Case ChrW$(360): c = "ò"
Case ChrW$(7908): c = "ô"
Case ChrW$(431): c = "¦"
Case ChrW$(7912): c = "ø"
Case ChrW$(7914): c = "õ"
Case ChrW$(7916): c = "ö"
Case ChrW$(7918): c = "÷"
Case ChrW$(7920): c = "ù"
Case ChrW$(89): c = "Y"
Case ChrW$(221): c = "ý"
Case ChrW$(7922): c = "ú"
Case ChrW$(7926): c = "û"
Case ChrW$(7928): c = "ü"
Case ChrW$(7924): c = "þ"
Case ChrW$(272): c = "§"
End Select
UNICODEtoTCVN3 = UNICODEtoTCVN3 + c
Next i
End Function
Function UNICODEtoVNI(vnstr As String)
Dim c As String, i As Long
For i = 1 To Len(vnstr)
c = Mid(vnstr, i, 1)
Select Case c
Case ChrW$(97): c = "a"
Case ChrW$(225): c = "aù"
Case ChrW$(224): c = "aø"
Case ChrW$(7843): c = "aû"
Case ChrW$(227): c = "aõ"
Case ChrW$(7841): c = "aï"
Case ChrW$(259): c = "aê"
Case ChrW$(7855): c = "aé"
Case ChrW$(7857): c = "aè"
Case ChrW$(7859): c = "aú"
Case ChrW$(7861): c = "aü"
Case ChrW$(7863): c = "aë"
Case ChrW$(226): c = "aâ"
Case ChrW$(7845): c = "aá"
Case ChrW$(7847): c = "aà"
Case ChrW$(7849): c = "aå"
Case ChrW$(7851): c = "aã"
Case ChrW$(7853): c = "aä"
Case ChrW$(101): c = "e"
Case ChrW$(233): c = "eù"
Case ChrW$(232): c = "eø"
Case ChrW$(7867): c = "eû"
Case ChrW$(7869): c = "eõ"
Case ChrW$(7865): c = "eï"
Case ChrW$(234): c = "eâ"
Case ChrW$(7871): c = "eá"
Case ChrW$(7873): c = "eà"
Case ChrW$(7875): c = "eå"
Case ChrW$(7877): c = "eã"
Case ChrW$(7879): c = "eä"
Case ChrW$(111): c = "o"
Case ChrW$(243): c = "où"
Case ChrW$(242): c = "oø"
Case ChrW$(7887): c = "oû"
Case ChrW$(245): c = "oõ"
Case ChrW$(7885): c = "oï"
Case ChrW$(244): c = "oâ"
Case ChrW$(7889): c = "oá"
Case ChrW$(7891): c = "oà"
Case ChrW$(7893): c = "oå"
Case ChrW$(7895): c = "oã"
Case ChrW$(7897): c = "oä"
Case ChrW$(417): c = "ô"
Case ChrW$(7899): c = "ôù"
Case ChrW$(7901): c = "ôø"
Case ChrW$(7903): c = "ôû"
Case ChrW$(7905): c = "ôõ"
Case ChrW$(7907): c = "ôï"
Case ChrW$(105): c = "i"
Case ChrW$(237): c = "í"
Case ChrW$(236): c = "ì"
Case ChrW$(7881): c = "æ"
Case ChrW$(297): c = "ó"
Case ChrW$(7883): c = "ò"
Case ChrW$(117): c = "u"
Case ChrW$(250): c = "uù"
Case ChrW$(249): c = "uø"
Case ChrW$(7911): c = "uû"
Case ChrW$(361): c = "uõ"
Case ChrW$(7909): c = "uï"
Case ChrW$(432): c = "ö"
Case ChrW$(7913): c = "öù"
Case ChrW$(7915): c = "uø"
Case ChrW$(7917): c = "öû"
Case ChrW$(7919): c = "öõ"
Case ChrW$(7921): c = "öï"
Case ChrW$(121): c = "y"
Case ChrW$(253): c = "yù"
Case ChrW$(7923): c = "yø"
Case ChrW$(7927): c = "yû"
Case ChrW$(7929): c = "yõ"
Case ChrW$(7925): c = "î"
Case ChrW$(273): c = "ñ"
Case ChrW$(65): c = "A"
Case ChrW$(193): c = "AÙ"
Case ChrW$(192): c = "AØ"
Case ChrW$(7842): c = "AÛ"
Case ChrW$(195): c = "AÕ"
Case ChrW$(7840): c = "AÏ"
Case ChrW$(258): c = "AÊ"
Case ChrW$(7854): c = "AÉ"
Case ChrW$(7856): c = "AÈ"
Case ChrW$(7858): c = "AÚ"
Case ChrW$(7860): c = "AÜ"
Case ChrW$(7862): c = "AË"
Case ChrW$(194): c = "AÂ"
Case ChrW$(7844): c = "AÁ"
Case ChrW$(7846): c = "AÀ"
Case ChrW$(7848): c = "AÅ"
Case ChrW$(7850): c = "AÃ"
Case ChrW$(7852): c = "AÄ"
Case ChrW$(69): c = "E"
Case ChrW$(201): c = "EÙ"
Case ChrW$(200): c = "EØ"
Case ChrW$(7866): c = "EÛ"
Case ChrW$(7868): c = "EÕ"
Case ChrW$(7864): c = "EÏ"
Case ChrW$(202): c = "EÂ"
Case ChrW$(7870): c = "EÁ"
Case ChrW$(7872): c = "EÀ"
Case ChrW$(7874): c = "EÅ"
Case ChrW$(7876): c = "EÃ"
Case ChrW$(7878): c = "EÄ"
Case ChrW$(79): c = "O"
Case ChrW$(211): c = "OÙ"
Case ChrW$(210): c = "OØ"
Case ChrW$(7886): c = "OÛ"
Case ChrW$(213): c = "OÕ"
Case ChrW$(7884): c = "OÏ"
Case ChrW$(212): c = "OÂ"
Case ChrW$(7888): c = "OÁ"
Case ChrW$(7890): c = "OÀ"
Case ChrW$(7892): c = "OÅ"
Case ChrW$(7894): c = "OÃ"
Case ChrW$(7896): c = "OÄ"
Case ChrW$(416): c = "Ô"
Case ChrW$(7898): c = "ÔÙ"
Case ChrW$(7900): c = "ÔØ"
Case ChrW$(7902): c = "ÔÛ"
Case ChrW$(7904): c = "ÔÕ"
Case ChrW$(7906): c = "ÔÏ"
Case ChrW$(73): c = "I"
Case ChrW$(205): c = "Í"
Case ChrW$(204): c = "Ì"
Case ChrW$(7880): c = "Æ"
Case ChrW$(296): c = "Ó"
Case ChrW$(7882): c = "Ò"
Case ChrW$(85): c = "U"
Case ChrW$(218): c = "UÙ"
Case ChrW$(217): c = "UØ"
Case ChrW$(7910): c = "UÛ"
Case ChrW$(360): c = "UÕ"
Case ChrW$(7908): c = "UÏ"
Case ChrW$(431): c = "Ö"
Case ChrW$(7912): c = "ÖÙ"
Case ChrW$(7914): c = "ÖØ"
Case ChrW$(7916): c = "ÖÛ"
Case ChrW$(7918): c = "ÖÕ"
Case ChrW$(7920): c = "ÖÏ"
Case ChrW$(89): c = "Y"
Case ChrW$(221): c = "YÙ"
Case ChrW$(7922): c = "YØ"
Case ChrW$(7926): c = "YÛ"
Case ChrW$(7928): c = "YÕ"
Case ChrW$(7924): c = "Î"
Case ChrW$(272): c = "Ñ"
End Select
UNICODEtoVNI = UNICODEtoVNI + c
Next i
End Function

Function VNItoUNICODE(vnstr As String)
Dim c As String, i As Long
Dim db As Boolean
For i = 1 To Len(vnstr)
db = False
If i < Len(vnstr) Then
c = Mid(vnstr, i + 1, 1)
If c = "ù" Or c = "ø" Or c = "û" Or c = "õ" Or c = "ï" Or _
c = "ê" Or c = "é" Or c = "è" Or c = "ú" Or c = "ü" Or c = "ë" Or _
c = "â" Or c = "á" Or c = "à" Or c = "å" Or c = "ã" Or c = "ä" Or _
c = "Ù" Or c = "Ø" Or c = "Û" Or c = "Õ" Or c = "Ï" Or _
c = "Ê" Or c = "É" Or c = "È" Or c = "Ú" Or c = "Ü" Or c = "Ë" Or _
c = "Â" Or c = "Á" Or c = "À" Or c = "Å" Or c = "Ã" Or c = "Ä" Then db = True
End If
If db Then
c = Mid(vnstr, i, 2)
Select Case c
Case "aù": c = ChrW$(225)
Case "aø": c = ChrW$(224)
Case "aû": c = ChrW$(7843)
Case "aõ": c = ChrW$(227)
Case "aï": c = ChrW$(7841)
Case "aê": c = ChrW$(259)
Case "aé": c = ChrW$(7855)
Case "aè": c = ChrW$(7857)
Case "aú": c = ChrW$(7859)
Case "aü": c = ChrW$(7861)
Case "aë": c = ChrW$(7863)
Case "aâ": c = ChrW$(226)
Case "aá": c = ChrW$(7845)
Case "aà": c = ChrW$(7847)
Case "aå": c = ChrW$(7849)
Case "aã": c = ChrW$(7851)
Case "aä": c = ChrW$(7853)
Case "eù": c = ChrW$(233)
Case "eø": c = ChrW$(232)
Case "eû": c = ChrW$(7867)
Case "eõ": c = ChrW$(7869)
Case "eï": c = ChrW$(7865)
Case "eâ": c = ChrW$(234)
Case "eá": c = ChrW$(7871)
Case "eà": c = ChrW$(7873)
Case "eå": c = ChrW$(7875)
Case "eã": c = ChrW$(7877)
Case "eä": c = ChrW$(7879)
Case "où": c = ChrW$(243)
Case "oø": c = ChrW$(242)
Case "oû": c = ChrW$(7887)
Case "oõ": c = ChrW$(245)
Case "oï": c = ChrW$(7885)
Case "oâ": c = ChrW$(244)
Case "oá": c = ChrW$(7889)
Case "oà": c = ChrW$(7891)
Case "oå": c = ChrW$(7893)
Case "oã": c = ChrW$(7895)
Case "oä": c = ChrW$(7897)
Case "ôù": c = ChrW$(7899)
Case "ôø": c = ChrW$(7901)
Case "ôû": c = ChrW$(7903)
Case "ôõ": c = ChrW$(7905)
Case "ôï": c = ChrW$(7907)
Case "uù": c = ChrW$(250)
Case "uø": c = ChrW$(249)
Case "uû": c = ChrW$(7911)
Case "uõ": c = ChrW$(361)
Case "uï": c = ChrW$(7909)
Case "öù": c = ChrW$(7913)
Case "öø": c = ChrW$(7915)
Case "öû": c = ChrW$(7917)
Case "öõ": c = ChrW$(7919)
Case "öï": c = ChrW$(7921)
Case "yù": c = ChrW$(253)
Case "yø": c = ChrW$(7923)
Case "yû": c = ChrW$(7927)
Case "yõ": c = ChrW$(7929)
Case "AÙ": c = ChrW$(193)
Case "AØ": c = ChrW$(192)
Case "AÛ": c = ChrW$(7842)
Case "AÕ": c = ChrW$(195)
Case "AÏ": c = ChrW$(7840)
Case "AÊ": c = ChrW$(258)
Case "AÉ": c = ChrW$(7854)
Case "AÈ": c = ChrW$(7856)
Case "AÚ": c = ChrW$(7858)
Case "AÜ": c = ChrW$(7860)
Case "AË": c = ChrW$(7862)
Case "AÂ": c = ChrW$(194)
Case "AÁ": c = ChrW$(7844)
Case "AÀ": c = ChrW$(7846)
Case "AÅ": c = ChrW$(7848)
Case "AÃ": c = ChrW$(7850)
Case "AÄ": c = ChrW$(7852)
Case "EÙ": c = ChrW$(201)
Case "EØ": c = ChrW$(200)
Case "EÛ": c = ChrW$(7866)
Case "EÕ": c = ChrW$(7868)
Case "EÏ": c = ChrW$(7864)
Case "EÂ": c = ChrW$(202)
Case "EÁ": c = ChrW$(7870)
Case "EÀ": c = ChrW$(7872)
Case "EÅ": c = ChrW$(7874)
Case "EÃ": c = ChrW$(7876)
Case "EÄ": c = ChrW$(7878)
Case "OÙ": c = ChrW$(211)
Case "OØ": c = ChrW$(210)
Case "OÛ": c = ChrW$(7886)
Case "OÕ": c = ChrW$(213)
Case "OÏ": c = ChrW$(7884)
Case "OÂ": c = ChrW$(212)
Case "OÁ": c = ChrW$(7888)
Case "OÀ": c = ChrW$(7890)
Case "OÅ": c = ChrW$(7892)
Case "OÃ": c = ChrW$(7894)
Case "OÄ": c = ChrW$(7896)
Case "ÔÙ": c = ChrW$(7898)
Case "ÔØ": c = ChrW$(7900)
Case "ÔÛ": c = ChrW$(7902)
Case "ÔÕ": c = ChrW$(7904)
Case "ÔÏ": c = ChrW$(7906)
Case "UÙ": c = ChrW$(218)
Case "UØ": c = ChrW$(217)
Case "UÛ": c = ChrW$(7910)
Case "UÕ": c = ChrW$(360)
Case "UÏ": c = ChrW$(7908)
Case "ÖÙ": c = ChrW$(7912)
Case "ÖØ": c = ChrW$(7914)
Case "ÖÛ": c = ChrW$(7916)
Case "ÖÕ": c = ChrW$(7918)
Case "ÖÏ": c = ChrW$(7920)
Case "YÙ": c = ChrW$(221)
Case "YØ": c = ChrW$(7922)
Case "YÛ": c = ChrW$(7926)
Case "YÕ": c = ChrW$(7928)
End Select
Else
c = Mid(vnstr, i, 1)
Select Case c
Case "ô": c = ChrW$(417)
Case "í": c = ChrW$(237)
Case "ì": c = ChrW$(236)
Case "æ": c = ChrW$(7881)
Case "ó": c = ChrW$(297)
Case "ò": c = ChrW$(7883)
Case "ö": c = ChrW$(432)
Case "î": c = ChrW$(7925)
Case "ñ": c = ChrW$(273)
Case "Ô": c = ChrW$(416)
Case "Í": c = ChrW$(205)
Case "Ì": c = ChrW$(204)
Case "Æ": c = ChrW$(7880)
Case "Ó": c = ChrW$(296)
Case "Ò": c = ChrW$(7882)
Case "Ö": c = ChrW$(431)
Case "Î": c = ChrW$(7924)
Case "Ñ": c = ChrW$(272)
End Select
End If
VNItoUNICODE = VNItoUNICODE + c
If db Then i = i + 1
Next i
End Function
Function VNItoTCVN3(vnstr As String)
Dim c As String, i As Long
Dim db As Boolean
For i = 1 To Len(vnstr)
db = False
If i < Len(vnstr) Then
c = Mid(vnstr, i + 1, 1)
If c = "ù" Or c = "ø" Or c = "û" Or c = "õ" Or c = "ï" Or _
c = "ê" Or c = "é" Or c = "è" Or c = "ú" Or c = "ü" Or c = "ë" Or _
c = "â" Or c = "á" Or c = "à" Or c = "å" Or c = "ã" Or c = "ä" Or _
c = "Ù" Or c = "Ø" Or c = "Û" Or c = "Õ" Or c = "Ï" Or _
c = "Ê" Or c = "É" Or c = "È" Or c = "Ú" Or c = "Ü" Or c = "Ë" Or _
c = "Â" Or c = "Á" Or c = "À" Or c = "Å" Or c = "Ã" Or c = "Ä" Then db = True
End If
If db Then
c = Mid(vnstr, i, 2)
Select Case c
Case "aù": c = "¸"
Case "aø": c = "µ"
Case "aû": c = "¶"
Case "aõ": c = "·"
Case "aï": c = "¹"
Case "aê": c = "¨"
Case "aé": c = "¾"
Case "aè": c = "»"
Case "aú": c = "¼"
Case "aü": c = "½"
Case "aë": c = "Æ"
Case "aâ": c = "©"
Case "aá": c = "Ê"
Case "aà": c = "Ç"
Case "aå": c = "È"
Case "aã": c = "É"
Case "aä": c = "Ë"
Case "eù": c = "Ð"
Case "eø": c = "Ì"
Case "eû": c = "Î"
Case "eõ": c = "Ï"
Case "eï": c = "Ñ"
Case "eâ": c = "ª"
Case "eá": c = "Õ"
Case "eà": c = "Ò"
Case "eå": c = "Ó"
Case "eã": c = "Ô"
Case "eä": c = "Ö"
Case "où": c = "ã"
Case "oø": c = "ß"
Case "oû": c = "á"
Case "oõ": c = "â"
Case "oï": c = "ä"
Case "oâ": c = "«"
Case "oá": c = "è"
Case "oà": c = "å"
Case "oå": c = "æ"
Case "oã": c = "ç"
Case "oä": c = "é"
Case "ôù": c = "í"
Case "ôø": c = "ê"
Case "ôû": c = "ë"
Case "ôõ": c = "ì"
Case "ôï": c = "î"
Case "uù": c = "ó"
Case "uø": c = "ï"
Case "uû": c = "ñ"
Case "uõ": c = "ò"
Case "uï": c = "ô"
Case "öù": c = "ø"
Case "öø": c = "õ"
Case "öû": c = "ö"
Case "öõ": c = "÷"
Case "öï": c = "ù"
Case "yù": c = "ý"
Case "yø": c = "ú"
Case "yû": c = "û"
Case "yõ": c = "ü"
Case "AÙ": c = "¸"
Case "AØ": c = "µ"
Case "AÛ": c = "¶"
Case "AÕ": c = "·"
Case "AÏ": c = "¹"
Case "AÉ": c = "¾"
Case "AÈ": c = "»"
Case "AÚ": c = "¼"
Case "AÜ": c = "½"
Case "AË": c = "Æ"
Case "AÁ": c = "Ê"
Case "AÀ": c = "Ç"
Case "AÅ": c = "È"
Case "AÃ": c = "É"
Case "AÄ": c = "Ë"
Case "EÙ": c = "Ð"
Case "EØ": c = "Ì"
Case "EÛ": c = "Î"
Case "EÕ": c = "Ï"
Case "EÏ": c = "Ñ"
Case "EÁ": c = "Õ"
Case "EÀ": c = "Ò"
Case "EÅ": c = "Ó"
Case "EÃ": c = "Ô"
Case "EÄ": c = "Ö"
Case "OÙ": c = "ã"
Case "OØ": c = "ß"
Case "OÛ": c = "á"
Case "OÕ": c = "â"
Case "OÏ": c = "ä"
Case "OÁ": c = "è"
Case "OÀ": c = "å"
Case "OÅ": c = "æ"
Case "OÃ": c = "ç"
Case "OÄ": c = "é"
Case "ÔÙ": c = "í"
Case "ÔØ": c = "ê"
Case "ÔÛ": c = "ë"
Case "ÔÕ": c = "ì"
Case "ÔÏ": c = "î"
Case "UÙ": c = "ó"
Case "UØ": c = "ï"
Case "UÛ": c = "ñ"
Case "UÕ": c = "ò"
Case "UÏ": c = "ô"
Case "ÖÙ": c = "ø"
Case "ÖØ": c = "õ"
Case "ÖÛ": c = "ö"
Case "ÖÕ": c = "÷"
Case "ÖÏ": c = "ù"
Case "YÙ": c = "ý"
Case "YØ": c = "ú"
Case "YÛ": c = "û"
Case "YÕ": c = "ü"
Case "AÊ": c = "¡"
Case "AÂ": c = "¢"
Case "EÂ": c = "£"
Case "OÂ": c = "¤"
End Select
Else
c = Mid(vnstr, i, 1)
Select Case c
Case "ô": c = "¬"
Case "i": c = "i"
Case "í": c = "Ý"
Case "ì": c = "×"
Case "æ": c = "Ø"
Case "ó": c = "Ü"
Case "ò": c = "Þ"
Case "ö": c = "­"
Case "î": c = "þ"
Case "ñ": c = "®"
Case "A": c = "A"
Case "Ô": c = "¥"
Case "I": c = "I"
Case "Í": c = "Æ"
Case "Ý": c = "Ø"
Case "U": c = "U"
Case "Ö": c = "¦"
Case "Y": c = "Y"
Case "Ñ": c = "§"
End Select
End If
VNItoTCVN3 = VNItoTCVN3 + c
If db Then i = i + 1
Next i
End Function
Function TCVN3fromVNI(vnstr As String)
TCVN3fromVNI = VNItoTCVN3(vnstr)
End Function
Function TCVN3fromUNICODE(vnstr As String)
TCVN3fromUNICODE = UNICODEtoTCVN3(vnstr)
End Function
Function VNIfromTCVN3(vnstr As String)
VNIfromTCVN3 = TCVN3toVNI(vnstr)
End Function
Function VNIfromUNICODE(vnstr As String)
VNIfromUNICODE = UNICODEtoVNI(vnstr)
End Function
Function UNICODEfromVNI(vnstr As String)
UNICODEfromVNI = VNItoUNICODE(vnstr)
End Function
Function UNICODEfromTCVN3(vnstr As String)
UNICODEfromTCVN3 = TCVN3toUNICODE(vnstr)
End Function
Function UPPERUni(ByVal vnstr As String)
Dim c As String, i As Long
vnstr = UCase(vnstr)
For i = 1 To Len(vnstr)
c = Mid(vnstr, i, 1)
Select Case c
Case ChrW$(97): c = ChrW$(65)
Case ChrW$(225): c = ChrW$(193)
Case ChrW$(224): c = ChrW$(192)
Case ChrW$(7843): c = ChrW$(7842)
Case ChrW$(227): c = ChrW$(195)
Case ChrW$(7841): c = ChrW$(7840)
Case ChrW$(259): c = ChrW$(258)
Case ChrW$(7855): c = ChrW$(7854)
Case ChrW$(7857): c = ChrW$(7856)
Case ChrW$(7859): c = ChrW$(7858)
Case ChrW$(7861): c = ChrW$(7860)
Case ChrW$(7863): c = ChrW$(7862)
Case ChrW$(226): c = ChrW$(194)
Case ChrW$(7845): c = ChrW$(7844)
Case ChrW$(7847): c = ChrW$(7846)
Case ChrW$(7849): c = ChrW$(7848)
Case ChrW$(7851): c = ChrW$(7850)
Case ChrW$(7853): c = ChrW$(7852)
Case ChrW$(101): c = ChrW$(69)
Case ChrW$(233): c = ChrW$(201)
Case ChrW$(232): c = ChrW$(200)
Case ChrW$(7867): c = ChrW$(7866)
Case ChrW$(7869): c = ChrW$(7868)
Case ChrW$(7865): c = ChrW$(7864)
Case ChrW$(234): c = ChrW$(202)
Case ChrW$(7871): c = ChrW$(7870)
Case ChrW$(7873): c = ChrW$(7872)
Case ChrW$(7875): c = ChrW$(7874)
Case ChrW$(7877): c = ChrW$(7876)
Case ChrW$(7879): c = ChrW$(7878)
Case ChrW$(111): c = ChrW$(79)
Case ChrW$(243): c = ChrW$(211)
Case ChrW$(242): c = ChrW$(210)
Case ChrW$(7887): c = ChrW$(7886)
Case ChrW$(245): c = ChrW$(213)
Case ChrW$(7885): c = ChrW$(7884)
Case ChrW$(244): c = ChrW$(212)
Case ChrW$(7889): c = ChrW$(7888)
Case ChrW$(7891): c = ChrW$(7890)
Case ChrW$(7893): c = ChrW$(7892)
Case ChrW$(7895): c = ChrW$(7894)
Case ChrW$(7897): c = ChrW$(7896)
Case ChrW$(417): c = ChrW$(416)
Case ChrW$(7899): c = ChrW$(7898)
Case ChrW$(7901): c = ChrW$(7900)
Case ChrW$(7903): c = ChrW$(7902)
Case ChrW$(7905): c = ChrW$(7904)
Case ChrW$(7907): c = ChrW$(7906)
Case ChrW$(105): c = ChrW$(73)
Case ChrW$(237): c = ChrW$(205)
Case ChrW$(236): c = ChrW$(204)
Case ChrW$(7881): c = ChrW$(7880)
Case ChrW$(297): c = ChrW$(296)
Case ChrW$(7883): c = ChrW$(7882)
Case ChrW$(117): c = ChrW$(85)
Case ChrW$(250): c = ChrW$(218)
Case ChrW$(249): c = ChrW$(217)
Case ChrW$(7911): c = ChrW$(7910)
Case ChrW$(361): c = ChrW$(360)
Case ChrW$(7909): c = ChrW$(7908)
Case ChrW$(432): c = ChrW$(431)
Case ChrW$(7913): c = ChrW$(7912)
Case ChrW$(7915): c = ChrW$(7914)
Case ChrW$(7917): c = ChrW$(7916)
Case ChrW$(7919): c = ChrW$(7918)
Case ChrW$(7921): c = ChrW$(7920)
Case ChrW$(121): c = ChrW$(89)
Case ChrW$(253): c = ChrW$(221)
Case ChrW$(7923): c = ChrW$(7922)
Case ChrW$(7927): c = ChrW$(7926)
Case ChrW$(7929): c = ChrW$(7928)
Case ChrW$(7925): c = ChrW$(7924)
Case ChrW$(273): c = ChrW$(272)
End Select
Next i
UPPERUni = vnstr
End Function
Function lowerUni(ByVal vnstr As String)
Dim c As String, i As Long
vnstr = LCase(vnstr)
For i = 1 To Len(vnstr)
c = Mid(vnstr, i, 1)
Select Case c
Case ChrW$(97): c = ChrW$(65)
Case ChrW$(225): c = ChrW$(193)
Case ChrW$(224): c = ChrW$(192)
Case ChrW$(7843): c = ChrW$(7842)
Case ChrW$(227): c = ChrW$(195)
Case ChrW$(7841): c = ChrW$(7840)
Case ChrW$(259): c = ChrW$(258)
Case ChrW$(7855): c = ChrW$(7854)
Case ChrW$(7857): c = ChrW$(7856)
Case ChrW$(7859): c = ChrW$(7858)
Case ChrW$(7861): c = ChrW$(7860)
Case ChrW$(7863): c = ChrW$(7862)
Case ChrW$(226): c = ChrW$(194)
Case ChrW$(7845): c = ChrW$(7844)
Case ChrW$(7847): c = ChrW$(7846)
Case ChrW$(7849): c = ChrW$(7848)
Case ChrW$(7851): c = ChrW$(7850)
Case ChrW$(7853): c = ChrW$(7852)
Case ChrW$(101): c = ChrW$(69)
Case ChrW$(233): c = ChrW$(201)
Case ChrW$(232): c = ChrW$(200)
Case ChrW$(7867): c = ChrW$(7866)
Case ChrW$(7869): c = ChrW$(7868)
Case ChrW$(7865): c = ChrW$(7864)
Case ChrW$(234): c = ChrW$(202)
Case ChrW$(7871): c = ChrW$(7870)
Case ChrW$(7873): c = ChrW$(7872)
Case ChrW$(7875): c = ChrW$(7874)
Case ChrW$(7877): c = ChrW$(7876)
Case ChrW$(7879): c = ChrW$(7878)
Case ChrW$(111): c = ChrW$(79)
Case ChrW$(243): c = ChrW$(211)
Case ChrW$(242): c = ChrW$(210)
Case ChrW$(7887): c = ChrW$(7886)
Case ChrW$(245): c = ChrW$(213)
Case ChrW$(7885): c = ChrW$(7884)
Case ChrW$(244): c = ChrW$(212)
Case ChrW$(7889): c = ChrW$(7888)
Case ChrW$(7891): c = ChrW$(7890)
Case ChrW$(7893): c = ChrW$(7892)
Case ChrW$(7895): c = ChrW$(7894)
Case ChrW$(7897): c = ChrW$(7896)
Case ChrW$(417): c = ChrW$(416)
Case ChrW$(7899): c = ChrW$(7898)
Case ChrW$(7901): c = ChrW$(7900)
Case ChrW$(7903): c = ChrW$(7902)
Case ChrW$(7905): c = ChrW$(7904)
Case ChrW$(7907): c = ChrW$(7906)
Case ChrW$(105): c = ChrW$(73)
Case ChrW$(237): c = ChrW$(205)
Case ChrW$(236): c = ChrW$(204)
Case ChrW$(7881): c = ChrW$(7880)
Case ChrW$(297): c = ChrW$(296)
Case ChrW$(7883): c = ChrW$(7882)
Case ChrW$(117): c = ChrW$(85)
Case ChrW$(250): c = ChrW$(218)
Case ChrW$(249): c = ChrW$(217)
Case ChrW$(7911): c = ChrW$(7910)
Case ChrW$(361): c = ChrW$(360)
Case ChrW$(7909): c = ChrW$(7908)
Case ChrW$(432): c = ChrW$(431)
Case ChrW$(7913): c = ChrW$(7912)
Case ChrW$(7915): c = ChrW$(7914)
Case ChrW$(7917): c = ChrW$(7916)
Case ChrW$(7919): c = ChrW$(7918)
Case ChrW$(7921): c = ChrW$(7920)
Case ChrW$(121): c = ChrW$(89)
Case ChrW$(253): c = ChrW$(221)
Case ChrW$(7923): c = ChrW$(7922)
Case ChrW$(7927): c = ChrW$(7926)
Case ChrW$(7929): c = ChrW$(7928)
Case ChrW$(7925): c = ChrW$(7924)
Case ChrW$(273): c = ChrW$(272)
End Select
Next i
lowerUni = vnstr
End Function
Function ProperUni(ByVal vnstr As String)
Dim c As String, i As Long
vnstr = lowerUni(vnstr)
For i = 1 To Len(vnstr)
c = Mid(vnstr, i, 1)
If i = 1 Then
c = UPPERUni(c)
Else
If Mid(vnstr, i - 1, 1) = " " Then
c = UPPERUni(c)
End If
End If
ProperUni = ProperUni & c
Next i
If Len(vnstr) = 0 Then ProperUni = ""
End Function
Function ProperVni(ByVal vnstr As String)
Dim c As String, i As Long
vnstr = ProperUni(vnstr)
If Len(vnstr) >= 1 Then ProperVni = UCase(Left(vnstr, 1))
For i = 2 To Len(vnstr)
c = Mid(vnstr, i, 1)
If ((c = "ù") Or (c = "ø") Or (c = "û") Or (c = "õ") _
Or (c = "ï") Or (c = "ê") Or (c = "è") Or (c = "é") _
Or (c = "ú") Or (c = "ü") Or (c = "ë") Or (c = "â") _
Or (c = "á") Or (c = "à") Or (c = "å") Or (c = "ã") _
Or (c = "ä")) Then
If i = 2 Then
c = UCase(c)
Else
If Mid(vnstr, i - 2, 1) = " " Then
c = UCase(c)
End If
End If
End If
ProperVni = ProperVni & c
Next i
If Len(vnstr) = 0 Then ProperVni = ""
End Function

 

Nguồn : Sưu tầm


EmoticonEmoticon