vb同音字查询

来源:百度知道 编辑:UC知道 时间:2024/05/25 07:06:46
在username.text中输入人的姓名如果输入错了比如"李暮然" 输入成“里墓然”也能查询到。怎么实现啊。知道的帮帮忙。谢谢了

思路:
那就用其拼音首字来匹配,数据库中先将“李暮然”生成关键字“LMR”,在查询前,也将用户的输入生成关键字“LMR”,再将2个字符串进行比较。

李暮然生成为字符LMR的方法,请参考下面的代码,但这个代码只能转换一个字,即将李转换为L,你需要再改一下:
Public Function GetPY(ByVal strParmeter As String) As String
Dim intTmp As String, i As Long
For i = 1 To Len(strParmeter)
intTmp = Asc(Mid(strParmeter, i, 1))

If intTmp < Asc("啊") Then
GetPY = GetPY & "*"
ElseIf intTmp >= Asc("啊") And intTmp < Asc("芭") Then
GetPY = GetPY & "a"
ElseIf intTmp >= Asc("芭") And intTmp < Asc("擦") Then
GetPY = GetPY & "b"
ElseIf intTmp >= Asc("擦") And intTmp < Asc("搭") Then
GetPY = GetPY & "c"
ElseIf intTmp >= Asc("搭") And intTmp < Asc("蛾") Then