zoukankan      html  css  js  c++  java
  • Excel文本获取拼音

    【说明】

    版本:Excel 2010

    文件后缀:.xls

    有在.xlsb文件下使用未成功。建议使用.xls后缀。

    1、调出“开发工具”

    步骤:文件-->选项-->自定义功能区-->勾选“开发工具”-->确定

    2、开发工具-->Visual Basic 

    开发VB应用

    3、插入-->  模块

    在插入模块的编辑器,空白处粘贴如下代码

    Function pinyin(p As String) As String
    i = Asc(p)
    Select Case i
    Case -20319 To -20284: pinyin = "A"
    Case -20283 To -19776: pinyin = "B"
    Case -19775 To -19219: pinyin = "C"
    Case -19218 To -18711: pinyin = "D"
    Case -18710 To -18527: pinyin = "E"
    Case -18526 To -18240: pinyin = "F"
    Case -18239 To -17923: pinyin = "G"
    Case -17922 To -17418: pinyin = "H"
    Case -17417 To -16475: pinyin = "J"
    Case -16474 To -16213: pinyin = "K"
    Case -16212 To -15641: pinyin = "L"
    Case -15640 To -15166: pinyin = "M"
    Case -15165 To -14923: pinyin = "N"
    Case -14922 To -14915: pinyin = "O"
    Case -14914 To -14631: pinyin = "P"
    Case -14630 To -14150: pinyin = "Q"
    Case -14149 To -14091: pinyin = "R"
    Case -14090 To -13319: pinyin = "S"
    Case -13318 To -12839: pinyin = "T"
    Case -12838 To -12557: pinyin = "W"
    Case -12556 To -11848: pinyin = "X"
    Case -11847 To -11056: pinyin = "Y"
    Case -11055 To -2050: pinyin = "Z"
    Case Else: pinyin = p
    End Select
    End Function
    Function getpy(str)
    For i = 1 To Len(str)
    getpy = getpy & pinyin(Mid(str, i, 1))
    Next i
    End Function

    4、然后保存,如果出现如下提示,点击“确定”,然后关闭VB编辑器

    5、关闭VB后,就可以在Excel中测试看是否成功能,函数和使用微软自带函数一样使用。

    效果如下

  • 相关阅读:
    11-3 多道批处理系统
    URAL 1108 简单的树形dp背包问题
    POJ 2486 树形dp
    HDU 2242 连通分量缩点+树形dp
    POJ 3140 Contestants Division
    POJ 2378 Tree Cutting
    ZOJ 3201 树形背包问题
    POJ 1655 Balancing Act && POJ 3107 Godfather
    COJ 1351 Tree Counting 动态规划
    codeforces 219D 树形dp
  • 原文地址:https://www.cnblogs.com/chenv/p/9112228.html
Copyright © 2011-2022 走看看