在excel中实现汉字转换拼音首字母大写

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

在excel 2003和2007中已经验证成功。代码为网上收集,原作者已不可考。

[vb] view plain copy print ?
  1. Function getpychar(char)  
  2. tmp = 65536 + Asc(char)  
  3. If (tmp >= 45217 And tmp <= 45252) Then  
  4. getpychar = "A"  
  5. ElseIf (tmp >= 45253 And tmp <= 45760) Then  
  6. getpychar = "B"  
  7. ElseIf (tmp >= 45761 And tmp <= 46317) Then  
  8. getpychar = "C"  
  9. ElseIf (tmp >= 46318 And tmp <= 46825) Then  
  10. getpychar = "D"  
  11. ElseIf (tmp >= 46826 And tmp <= 47009) Then  
  12. getpychar = "E"  
  13. ElseIf (tmp >= 47010 And tmp <= 47296) Then  
  14. getpychar = "F"  
  15. ElseIf (tmp >= 47297 And tmp <= 47613) Then  
  16. getpychar = "G"  
  17. ElseIf (tmp >= 47614 And tmp <= 48118) Then  
  18. getpychar = "H"  
  19. ElseIf (tmp >= 48119 And tmp <= 49061) Then  
  20. getpychar = "J"  
  21. ElseIf (tmp >= 49062 And tmp <= 49323) Then  
  22. getpychar = "K"  
  23. ElseIf (tmp >= 49324 And tmp <= 49895) Then  
  24. getpychar = "L"  
  25. ElseIf (tmp >= 49896 And tmp <= 50370) Then  
  26. getpychar = "M"  
  27. ElseIf (tmp >= 50371 And tmp <= 50613) Then  
  28. getpychar = "N"  
  29. ElseIf (tmp >= 50614 And tmp <= 50621) Then  
  30. getpychar = "O"  
  31. ElseIf (tmp >= 50622 And tmp <= 50905) Then  
  32. getpychar = "P"  
  33. ElseIf (tmp >= 50906 And tmp <= 51386) Then  
  34. getpychar = "Q"  
  35. ElseIf (tmp >= 51387 And tmp <= 51445) Then  
  36. getpychar = "R"  
  37. ElseIf (tmp >= 51446 And tmp <= 52217) Then  
  38. getpychar = "S"  
  39. ElseIf (tmp >= 52218 And tmp <= 52697) Then  
  40. getpychar = "T"  
  41. ElseIf (tmp >= 52698 And tmp <= 52979) Then  
  42. getpychar = "W"  
  43. ElseIf (tmp >= 52980 And tmp <= 53640) Then  
  44. getpychar = "X"  
  45. ElseIf (tmp >= 53689 And tmp <= 54480) Then  
  46. getpychar = "Y"  
  47. ElseIf (tmp >= 54481 And tmp <= 62289) Then  
  48. getpychar = "Z"  
  49. Else '如果不是中文,则不处理  
  50. getpychar = char  
  51. End If  
  52. End Function  
  53. Function getpy(str)  
  54. For i = 1 To Len(str)  
  55. getpy = getpy & getpychar(Mid(str, i, 1))  
  56. Next i  
  57. End Function   
Function getpychar(char)tmp = 65536 + Asc(char)If (tmp >= 45217 And tmp <= 45252) Thengetpychar = "A"ElseIf (tmp >= 45253 And tmp <= 45760) Thengetpychar = "B"ElseIf (tmp >= 45761 And tmp <= 46317) Thengetpychar = "C"ElseIf (tmp >= 46318 And tmp <= 46825) Thengetpychar = "D"ElseIf (tmp >= 46826 And tmp <= 47009) Thengetpychar = "E"ElseIf (tmp >= 47010 And tmp <= 47296) Thengetpychar = "F"ElseIf (tmp >= 47297 And tmp <= 47613) Thengetpychar = "G"ElseIf (tmp >= 47614 And tmp <= 48118) Thengetpychar = "H"ElseIf (tmp >= 48119 And tmp <= 49061) Thengetpychar = "J"ElseIf (tmp >= 49062 And tmp <= 49323) Thengetpychar = "K"ElseIf (tmp >= 49324 And tmp <= 49895) Thengetpychar = "L"ElseIf (tmp >= 49896 And tmp <= 50370) Thengetpychar = "M"ElseIf (tmp >= 50371 And tmp <= 50613) Thengetpychar = "N"ElseIf (tmp >= 50614 And tmp <= 50621) Thengetpychar = "O"ElseIf (tmp >= 50622 And tmp <= 50905) Thengetpychar = "P"ElseIf (tmp >= 50906 And tmp <= 51386) Thengetpychar = "Q"ElseIf (tmp >= 51387 And tmp <= 51445) Thengetpychar = "R"ElseIf (tmp >= 51446 And tmp <= 52217) Thengetpychar = "S"ElseIf (tmp >= 52218 And tmp <= 52697) Thengetpychar = "T"ElseIf (tmp >= 52698 And tmp <= 52979) Thengetpychar = "W"ElseIf (tmp >= 52980 And tmp <= 53640) Thengetpychar = "X"ElseIf (tmp >= 53689 And tmp <= 54480) Thengetpychar = "Y"ElseIf (tmp >= 54481 And tmp <= 62289) Thengetpychar = "Z"Else '如果不是中文,则不处理getpychar = charEnd IfEnd FunctionFunction getpy(str)For i = 1 To Len(str)getpy = getpy & getpychar(Mid(str, i, 1))Next iEnd Function

           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

在excel中实现汉字转换拼音首字母大写_第1张图片

你可能感兴趣的:(在excel中实现汉字转换拼音首字母大写)