十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
汉字转拼音缩写的函数(VB),转带音调的可能有点。。。
网站的建设创新互联专注网站定制,经验丰富,不做模板,主营网站定制开发.小程序定制开发,H5页面制作!给你焕然一新的设计体验!已为混凝土搅拌站等企业提供专业服务。
Public Function getPYChar(char As String) As String
Dim lChar As Long
lChar = 65536 + Asc(char)
If (lChar = 45217 And lChar = 45252) Then getPYChar = "A"
If (lChar = 45253 And lChar = 45760) Then getPYChar = "B"
If (lChar = 47761 And lChar = 46317) Then getPYChar = "C"
If (lChar = 46318 And lChar = 46825) Then getPYChar = "D"
If (lChar = 46826 And lChar = 47009) Then getPYChar = "E"
If (lChar = 47010 And lChar = 47296) Then getPYChar = "F"
If (lChar = 47297 And lChar = 47613) Then getPYChar = "G"
If (lChar = 47614 And lChar = 48118) Then getPYChar = "H"
If (lChar = 48119 And lChar = 49061) Then getPYChar = "J"
If (lChar = 49062 And lChar = 49323) Then getPYChar = "K"
If (lChar = 49324 And lChar = 49895) Then getPYChar = "L"
If (lChar = 49896 And lChar = 50370) Then getPYChar = "M"
If (lChar = 50371 And lChar = 50613) Then getPYChar = "N"
If (lChar = 50614 And lChar = 50621) Then getPYChar = "O"
If (lChar = 50622 And lChar = 50905) Then getPYChar = "P"
If (lChar = 50906 And lChar = 51386) Then getPYChar = "Q"
If (lChar = 51387 And lChar = 51445) Then getPYChar = "R"
If (lChar = 51446 And lChar = 52217) Then getPYChar = "S"
If (lChar = 52218 And lChar = 52697) Then getPYChar = "T"
If (lChar = 52698 And lChar = 52979) Then getPYChar = "W"
If (lChar = 52980 And lChar = 53640) Then getPYChar = "X"
If (lChar = 53689 And lChar = 54480) Then getPYChar = "Y"
If (lChar = 54481 And lChar = 52289) Then getPYChar = "Z"
End Function
Public Function getPY(str As String) As String
For i = 0 To Len(str) - 1
getPY = getPY getPYChar(Mid(str, i + 1, 1))
Next
End Function
360问答
vb6.0怎样实现汉字的拼音如text1输入“拼音”就msgbox(pinyin)
lpnwk LV12
2013-07-01
满意答案
husky0114
LV11
2013-07-02
我自己做了一个ocx'控件,可以输入一大段中文后可输出它的拼音,但前提是电脑可以联网 调用方式 Private Sub Command1_Click() py1.输入字符 = "你想要的文字" MsgBox py1.输出字符 End Sub 控件下载地址我发给你,注意到百度信息里查收
public string hz2py(string hz) //获得汉字的区位码
{
byte[] sarr = System.Text.Encoding.Default.GetBytes(hz);
int len = sarr.Length;
if (len1)
{
byte[] array = new byte[2];
array = System.Text.Encoding.Default.GetBytes(hz);
int i1 = (short)(array[0] - '\0');
int i2 = (short)(array[1] - '\0');
//unicode解码方式下的汉字码
// array = System.Text.Encoding.Unicode.GetBytes(hz);
// int i1 = (short)(array[0] - '\0');
// int i2 = (short)(array[1] - '\0');
// int t1 = Convert.ToInt32(i1,16);
// int t2 = Convert.ToInt32(i2,16);
两个Textbos(Text1和Text2),一个CommandButton(Command1)
参考代码
Private Sub Command1_Click()
With Text2
Select Case Text1.Text
Case "你"
.Text = "ni"
Case "好"
.Text = "hao"
Case "吗"
.Text = "ma"
Case "今"
.Text = "jin"
'……剩下的自己写吧
'很巨大的工程
End Select
End With
End Sub
如果你能搞到数据库的话就容易多了,直接用数据库查询的方法就行了
建立一个表,每个拼音都跟多个汉字对应。可以通过汉字,找出对应的一个拼音,也可以通过拼音,找出一堆汉字。