回覆列表
  • 1 # 短腿大王

    2、然後在表格中輸入姓名和拼音,製作成一個如圖的表格,製作完成後在鍵盤上同時按住Alt+F11進入VB視窗。

    Option Explicit

    Function PY(TT As String) As Variant

    Dim i%, temp$

    PY = ""

    For i = 1 To Len(TT)

    temp = Asc(Mid$(TT, i, 1))

    If temp > 255 Or temp < 0 Then

    PY = PY & pinyin(Mid$(TT, i, 1))

    Else

    PY = PY & LCase(Mid$(TT, i, 1))

    End If

    Next i

    End Function

    Function pinyin(myStr As String) As Variant

    On Error Resume Next

    myStr = StrConv(myStr, vbNarrow)

    If Asc(myStr) > 0 Or Err.Number = 1004 Then pinyin = ""

    pinyin = Application.WorksheetFunction.VLookup(myStr, [{"吖","A";"八","B";"嚓","C";"搭","D";"蛾","E";"發","F";"噶","G";"鉿","H";"擊","J";"咔","K";"垃","L";"媽","M";"拿","N";"噢","O";"啪","P";"七","Q";"然","R";"仨","S";"他","T";"挖","W";"夕","X";"壓","Y";"座","Z"}], 2)

    End Function

  • 中秋節和大豐收的關聯?
  • 為什麼有的夫妻常常吵架感情卻好,有的夫妻不吵架卻過成陌生人?