中文字符转拼音

发布网友 发布时间:2022-04-23 01:58

我来回答

3个回答

热心网友 时间:2023-09-28 20:01

仔细分析你的叙述,代码应该是这样的:
Private Sub Command1_Click()
p = Text1.Text
For I = 1 To Len(p)
Label1 = Label1 & pinyin(Mid(p, I, 1))
Next I
End Sub

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 -175: pinyin = "J"
Case -174 To -16213: pinyin = "K"
Case -16212 To -151: pinyin = "L"
Case -150 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 = " "
End Select
End Function
更多VB代码请关注我的博客:http://hi.baidu.com/zgmg/blog

热心网友 时间:2023-09-28 20:02

Private Sub Command1_Click()

p = Text1.Text
Label1.Caption = pinyin(p)

End Sub

Function pinyin(ByVal 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 -175: pinyin = "J"
Case -174 To -16213: pinyin = "K"
Case -16212 To -151: pinyin = "L"
Case -150 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"
End Select
End Function

热心网友 时间:2023-09-28 20:02

把Command1_Click()中的代码改为Label1.Caption = pinyin(Text1.Text)

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com