VB 在输入汉字时怎样自动出现拼音码
我有一个表,字段是A1,A2,如下:A1A2张Z李L王W树S利L伟W新X重C刚G..........我有两个文本框,text1和text2我想在text1输入“张树利”这...
我有一个表,字段是A1,A2,如下:
A1 A2
张 Z
李 L
王 W
树 S
利 L
伟 W
新 X
重 C
刚 G
..........
我有两个文本框,text1和text2
我想在text1输入“张树利”这个名字时,text2能自动出现“ZSL”这三个拼音码
(没有双引号),在输入“李树利”时,text2能自动出现“LSL”这三个拼音码
在输入“王树利”时,text2能自动出现“WSL”这三个拼音码,请各位高手指点一下,我
琢磨了好长时间了,脑袋都要炸了,谢谢。 展开
A1 A2
张 Z
李 L
王 W
树 S
利 L
伟 W
新 X
重 C
刚 G
..........
我有两个文本框,text1和text2
我想在text1输入“张树利”这个名字时,text2能自动出现“ZSL”这三个拼音码
(没有双引号),在输入“李树利”时,text2能自动出现“LSL”这三个拼音码
在输入“王树利”时,text2能自动出现“WSL”这三个拼音码,请各位高手指点一下,我
琢磨了好长时间了,脑袋都要炸了,谢谢。 展开
3个回答
展开全部
Private Sub Text1_Change()
Text2.Text = ""
For i = 1 To Len(Text1.Text)
Text2.Text = Text2.Text + py(Mid(Text1.Text, i, 1))
Next i
End Sub
Public Function py(mystr As String) As String
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
End Function
Text2.Text = ""
For i = 1 To Len(Text1.Text)
Text2.Text = Text2.Text + py(Mid(Text1.Text, i, 1))
Next i
End Sub
Public Function py(mystr As String) As String
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
End Function
展开全部
提供个思路:将两个表放在ACCESS中对应起来,当text1的值改变时(有Change事件),将拼音码填入Text2中
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你可以 用timer 时钟来扫描text1里的内容 如果内容变化 再在text2里显示。
显示的内容就调用text里的内容做字符串 分别对字符串的每个字符做汉到拼音首字母的转换
显示的内容就调用text里的内容做字符串 分别对字符串的每个字符做汉到拼音首字母的转换
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询