vb.net汉字拼音 vb怎么输出汉字( 二 )


Dim myPing As Long = 65536 + Asc(word)
Select Case myPing
Case 45217 To 45252
Return "A"
Case 45253 To 45760
Return "B"
Case 45761 To 46317
Return "C"
Case 46318 To 46825
Return "D"
Case 46826 To 47009
Return "E"
Case 47010 To 47296
Return "F"
Case 47297 To 47613
Return "G"
Case 47614 To 48118
Return "H"
Case 48119 To 49061
Return "J"
Case 49062 To 49323
Return "K"
Case 49324 To 49895
Return "L"
Case 49896 To 50370
Return "M"
Case 50371 To 50613
Return "N"
Case 50906 To 51386
Return "O"
Case 50622 To 50905
Return "P"
Case 45217 To 45252
Return "Q"
Case 51387 To 51445
Return "R"
Case 51446 To 52217
Return "S"
Case 52218 To 52697
Return "T"
Case 52698 To 52979
Return "W"
Case 52980 To 53640
Return "X"
Case 53689 To 54480
Return "Y"
Case 54481 To 65536
Return "Z"
Case Else
'返回原字符
Return word
End Select
End Function
End Class
Default.aspx--------------------------------------------------
%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Code_拼音模糊查找_Default" %
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head runat="server"
title拼音模糊查找/title
/head
body
form id="form1" runat="server"
div
asp:TextBox ID="words" runat="server"/asp:TextBox
asp:Button ID="se" runat="server" Text="搜索" Width="83px" /
br /
br /
简拼asp:TextBox ID="jp" runat="server" Width="93px"/asp:TextBox
br /
br /
相关词组br /
br /
asp:ListBox ID="ListBox1" runat="server" Height="123px" Width="126px"/asp:ListBox
/div
/form
/body
/html
如何用vb.net将汉字转换成拼音阿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);
int tmp=i1*256+i2;
string getpychar="*";//找不到拼音码的用*补位
if(tmp=45217tmp=45252){getpychar= "A";}
else if(tmp=45253tmp=45760){getpychar= "B";}
else if(tmp=47761tmp=46317){getpychar= "C";}
else if(tmp=46318tmp=46825){getpychar= "D";}
else if(tmp=46826tmp=47009){getpychar= "E";}
else if(tmp=47010tmp=47296){getpychar= "F";}
else if(tmp=47297tmp=47613){getpychar= "G";}
else if(tmp=47614tmp=48118){getpychar= "H";}
else if(tmp=48119tmp=49061){getpychar= "J";}
else if(tmp=49062tmp=49323){getpychar= "K";}
else if(tmp=49324tmp=49895){getpychar= "L";}
else if(tmp=49896tmp=50370){getpychar= "M";}
else if(tmp=50371tmp=50613){getpychar= "N";}
else if(tmp=50614tmp=50621){getpychar= "O";}
else if(tmp=50622tmp=50905){getpychar= "P";}
else if(tmp=50906tmp=51386){getpychar= "Q";}
else if(tmp=51387tmp=51445){getpychar= "R";}
else if(tmp=51446tmp=52217){getpychar= "S";}
else if(tmp=52218tmp=52697){getpychar= "T";}
else if(tmp=52698tmp=52979){getpychar= "W";}
else if(tmp=52980tmp=53640){getpychar= "X";}
else if(tmp=53689tmp=54480){getpychar= "Y";}
else if(tmp=54481tmp=55289){getpychar= "Z";}
return getpychar;
}
else
{
return hz;

推荐阅读