- Tham gia
- 21/12/07
- Bài viết
- 1,901
- Được thích
- 5,297
- Nghề nghiệp
- Kinh doanh các mặt hàng văn phòng phẩm
Gửi các bạn 2 hàm chuyển đổi, hỗ trợ nhập tiếng việt trực tiếp trong VBA.
1. Hàm UniVBA(Str)
UniVBA("Nguye64n Ca3nh Hoa2ng Danh") = "Nguyễn Cảnh Hoàng Danh"
1. Hàm UniVBA(Str)
UniVBA("Nguye64n Ca3nh Hoa2ng Danh") = "Nguyễn Cảnh Hoàng Danh"
PHP:
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
Lần chỉnh sửa cuối: