VB6获取多个汉字拼音的首字母,vba字符串转拼音

VB6获取多个汉字拼音的首字母,vba字符串转拼音

Function GetPY(ByVal StringABC As String) As String
    'vb 获取多个汉字拼音的首字母
    Dim Tmp As String, i As Long
    For i = 1 To Len(StringABC)
    Select Case Asc(Mid(StringABC, i, 1))
        Case -20319 To -20284: GetPY = GetPY & "A"
        Case -20283 To -19776: GetPY = GetPY & "B"
        Case -19775 To -19219: GetPY = GetPY & "C"
        Case -19218 To -18711: GetPY = GetPY & "D"
        Case -18710 To -18527: GetPY = GetPY & "E"
        Case -18526 To -18240: GetPY = GetPY & "F"
        Case -18239 To -17923: GetPY = GetPY & "G"
        Case -17922 To -17418: GetPY = GetPY & "H"
        Case -17417 To -16475: GetPY = GetPY & "J"
        Case -16474 To -16213: GetPY = GetPY & "K"
        Case -16212 To -15641: GetPY = GetPY & "L"
        Case -15640 To -15166: GetPY = GetPY & "M"
        Case -15165 To -14923: GetPY = GetPY & "N"
        Case -14922 To -14915: GetPY = GetPY & "O"
        Case -14914 To -14631: GetPY = GetPY & "P"
        Case -14630 To -14150: GetPY = GetPY & "Q"
        Case -14149 To -14091: GetPY = GetPY & "R"
        Case -14090 To -13319: GetPY = GetPY & "S"
        Case -13318 To -12839: GetPY = GetPY & "T"
        Case -12838 To -12557: GetPY = GetPY & "W"
        Case -12556 To -11848: GetPY = GetPY & "X"
        Case -11847 To -11056: GetPY = GetPY & "Y"
        Case -11055 To -10247: GetPY = GetPY & "Z"
        Case Else:  GetPY = GetPY & Mid(StringABC, i, 1)
    End Select
    Next
End Function
 Function GetPY2(ByVal strParmeter As String) As String
 '取字符串拼音首字母,Codeid=396
Dim intTmp As String, i As Long
For i = 1 To Len(strParmeter)
intTmp = Asc(Mid(strParmeter, i, 1))
If intTmp < Asc("啊") Then
GetPY2 = GetPY2 & "*"
ElseIf intTmp >= Asc("啊") And intTmp < Asc("芭") Then
GetPY2 = GetPY2 & "A"
ElseIf intTmp >= Asc("芭") And intTmp < Asc("擦") Then
GetPY2 = GetPY2 & "B"
ElseIf intTmp >= Asc("擦") And intTmp < Asc("搭") Then
GetPY2 = GetPY2 & "C"
ElseIf intTmp >= Asc("搭") And intTmp < Asc("蛾") Then
GetPY2 = GetPY2 & "D"
ElseIf intTmp >= Asc("蛾") And intTmp < Asc("发") Then
GetPY2 = GetPY2 & "E"
ElseIf intTmp >= Asc("发") And intTmp < Asc("噶") Then
GetPY2 = GetPY2 & "F"
ElseIf intTmp >= Asc("噶") And intTmp < Asc("哈") Then
GetPY2 = GetPY2 & "G"
ElseIf intTmp >= Asc("哈") And intTmp < Asc("击") Then
GetPY2 = GetPY2 & "H"
ElseIf intTmp >= Asc("击") And intTmp < Asc("喀") Then
GetPY2 = GetPY2 & "J"
ElseIf intTmp >= Asc("喀") And intTmp < Asc("垃") Then
GetPY2 = GetPY2 & "K"
ElseIf intTmp >= Asc("垃") And intTmp < Asc("妈") Then
GetPY2 = GetPY2 & "L"
ElseIf intTmp >= Asc("妈") And intTmp < Asc("拿") Then
GetPY2 = GetPY2 & "M"
ElseIf intTmp >= Asc("拿") And intTmp < Asc("哦") Then
GetPY2 = GetPY2 & "N"
ElseIf intTmp >= Asc("哦") And intTmp < Asc("啪") Then
GetPY2 = GetPY2 & "O"
ElseIf intTmp >= Asc("啪") And intTmp < Asc("期") Then
GetPY2 = GetPY2 & "P"
ElseIf intTmp >= Asc("期") And intTmp < Asc("然") Then
GetPY2 = GetPY2 & "Q"
ElseIf intTmp >= Asc("然") And intTmp < Asc("撒") Then
GetPY2 = GetPY2 & "R"
ElseIf intTmp >= Asc("撒") And intTmp < Asc("塌") Then
GetPY2 = GetPY2 & "S"
ElseIf intTmp >= Asc("塌") And intTmp < Asc("挖") Then
GetPY2 = GetPY2 & "T"
ElseIf intTmp >= Asc("挖") And intTmp < Asc("昔") Then
GetPY2 = GetPY2 & "W"
ElseIf intTmp >= Asc("昔") And intTmp < Asc("压") Then
GetPY2 = GetPY2 & "X"
ElseIf intTmp >= Asc("压") And intTmp < Asc("匝") Then
GetPY2 = GetPY2 & "Y"
ElseIf intTmp >= Asc("匝") And intTmp < 0 Then
GetPY2 = GetPY2 & "Z"
ElseIf (intTmp >= 65 And intTmp <= 91) Or (intTmp >= 97 And intTmp <= 123) Then
GetPY2 = GetPY2 & Mid(strParmeter, i, 1)
Else
GetPY2 = GetPY2 & "*"
End If
Next
End Function

Public Function Py(mystr As String) As String
'vb 获取汉字拼音的首字母
Dim i As Integer
i = Asc(mystr)
Select Case i
Case -20319 To -20284: Py = "A"
Case -20283 To -19776: Py = "B"
Case -19775 To -19219: Py = "C"
Case -19218 To -18711: Py = "D"
Case -18710 To -18527: Py = "E"
Case -18526 To -18240: Py = "F"
Case -18239 To -17923: Py = "G"
Case -17922 To -17418: Py = "H"
Case -17417 To -16475: Py = "J"
Case -16474 To -16213: Py = "K"
Case -16212 To -15641: Py = "L"
Case -15640 To -15166: Py = "M"
Case -15165 To -14923: Py = "N"
Case -14922 To -14915: Py = "O"
Case -14914 To -14631: Py = "P"
Case -14630 To -14150: Py = "Q"
Case -14149 To -14091: Py = "R"
Case -14090 To -13319: Py = "S"
Case -13318 To -12839: Py = "T"
Case -12838 To -12557: Py = "W"
Case -12556 To -11848: Py = "X"
Case -11847 To -11056: Py = "Y"
Case -11055 To -10247: Py = "Z"
Case Else: Py = mystr
End Select

你可能感兴趣的:(java,数据库,前端)