|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 ning84 于 2024-9-28 11:06 编辑
EXCEL中使用VBA自定义函数搞定繁体字与简体字互转 http://www.360doc.com/content/20/1109/13/72339616_944869967.shtml
- Option Explicit
- '声明部分:
- Private Declare Function LCMapString Lib "kernel32" Alias "LCMapStringA" (ByVal Locale As Long, ByVal dwMapFlags As Long, ByVal lpSrcStr As String, ByVal cchSrc As Long, ByVal lpDestStr As String, ByVal cchDest As Long) As Long
- Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
- '函数部分:
- '简转繁
- Public Function JtoF(ByVal Str As String) As String
- Dim STlen As Long
- Dim STf As String
- STlen = lstrlen(Str)
- STf = Space(STlen)
- LCMapString &H804, &H4000000, Str, STlen, STf, STlen
- JtoF = STf
- End Function
- '繁转简
- Public Function FtoJ(ByVal Str As String) As String
- Dim STlen As Long
- Dim STj As String
- STlen = lstrlen(Str)
- STj = Space(STlen)
- LCMapString &H804, &H2000000, Str, STlen, STj, STlen
- FtoJ = STj
- End Function
复制代码
|
|