[快捷功能]: | | |

汉字转拼音源码

[不指定 2007年1月25日星期四 15:34 | by 九天狼 | 出处:本站原创 ] | |
↓看看这下面↓
↑诱惑你自己↑
下面是模块代码,请将其复制到模块中.

'汉字转拼音
Public Function py(mystr As String) As String
 If Asc(mystr) < 0 Then
   If Asc(Left(mystr, 1)) < Asc("啊") Then
      py = "0"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("啊") And Asc(Left(mystr, 1)) < Asc("芭") Then
      py = "A"
      Exit Function
   End If
[separator]
   If Asc(Left(mystr, 1)) >= Asc("芭") And Asc(Left(mystr, 1)) < Asc("擦") Then
      py = "B"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("擦") And Asc(Left(mystr, 1)) < Asc("搭") Then
      py = "C"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("搭") And Asc(Left(mystr, 1)) < Asc("蛾") Then
      py = "D"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("蛾") And Asc(Left(mystr, 1)) < Asc("发") Then
      py = "E"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("发") And Asc(Left(mystr, 1)) < Asc("噶") Then
      py = "F"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("噶") And Asc(Left(mystr, 1)) < Asc("哈") Then
      py = "G"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("哈") And Asc(Left(mystr, 1)) < Asc("击") Then
      py = "H"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("击") And Asc(Left(mystr, 1)) < Asc("喀") Then
      py = "J"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("喀") And Asc(Left(mystr, 1)) < Asc("垃") Then
      py = "K"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("垃") And Asc(Left(mystr, 1)) < Asc("妈") Then
      py = "L"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("妈") And Asc(Left(mystr, 1)) < Asc("拿") Then
      py = "M"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("拿") And Asc(Left(mystr, 1)) < Asc("哦") Then
      py = "N"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("哦") And Asc(Left(mystr, 1)) < Asc("啪") Then
      py = "O"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("啪") And Asc(Left(mystr, 1)) < Asc("期") Then
      py = "P"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("期") And Asc(Left(mystr, 1)) < Asc("然") Then
      py = "Q"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("然") And Asc(Left(mystr, 1)) < Asc("撒") Then
      py = "R"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("撒") And Asc(Left(mystr, 1)) < Asc("塌") Then
      py = "S"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("塌") And Asc(Left(mystr, 1)) < Asc("挖") Then
      py = "T"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("挖") And Asc(Left(mystr, 1)) < Asc("昔") Then
      py = "W"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("昔") And Asc(Left(mystr, 1)) < Asc("压") Then
      py = "X"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("压") And Asc(Left(mystr, 1)) < Asc("匝") Then
      py = "Y"
      Exit Function
   End If
   If Asc(Left(mystr, 1)) >= Asc("匝") Then
      py = "Z"
      Exit Function
   End If
 Else
   If UCase(mystr) <= "Z" And UCase(mystr) >= "A" Then
      py = UCase(Left(mystr, 1))
     Else
      py = mystr
   End If
 End If

End Function
'汉字转拼音完


下面是使用代码:

Private Sub Text1_Change()'text1l输入时在label1中即时显示拼音
 If Option1.Value = True Then
    Label1.Caption = ""
    Dim a As Integer
    a = Len(Text1.Text)
    For i = 1 To a
        Label1.Caption = Label1.Caption & py(Mid(Text1.Text, i, 1))
    Next i
 End If
End Sub

Private Sub Command1_Click()'按command1后在label1显示拼音
 Dim a As Integer
 Label1.Caption = ""
 a = Len(Text1.Text)
 For i = 1 To a
     Label1.Caption = Label1.Caption & py(Mid(Text1.Text, i, 1))
 Next i
End Sub


最后编辑: 九天狼 编辑于2007年2月5日星期二 22:10
Tags:
VB代码 | 评论(1) | 引用(0) | 阅读(7707)
qin
2007年6月24日星期一 23:03
谢谢了
分页: 1/1 第一页 1 最后页
您也可用OpenID登入:
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]