中文查找方式

syncbiny 2002-03-03 01:41:53
有那位知道股票软件的查找股票的设计方法,主要是键入拼音头一个字母,可找出所有相应的汉字,键入几个开头字母后,就可找出词组。
...全文
51 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
syncbiny 2002-03-10
  • 打赏
  • 举报
回复
我最初的设想是输入拼音字母头后,先得出词组,再道字段中查找,后参考了大家的帖子,我否定了,原因有2:一是拼音字头所得词组不好确定,智能拼音输入法中,需要先把拼音全部输入,选字后才确定、进库。下次再用时才能只输拼音头。二是词组太多,我的程序不是单独用来查询的,查找只是其中的一个小功能。词组太多,影响运行速度。
就如wjying(葡萄) 所说,要建立对应表。
我已改变查询方式,避开此问题,谢谢大家的热心,分先给了,那位网友有通过拼音字得汉字列表的,就如袁飞的拼音控件的功能一样,请告之,我会另发贴加分。quan_quan_baby@sohu.com
fanpingli 2002-03-08
  • 打赏
  • 举报
回复
最好的方法是建一个数据库.我们公司以前就是这么做的.
还有,根据汉字的编码来判断时,有些字的编码方法不是按正常的拼音字母排的,所以用的时候要注意特例.而且还有多音字!
syncbiny 2002-03-08
  • 打赏
  • 举报
回复
我尽快实验,谢谢
Tadpole0510 2002-03-05
  • 打赏
  • 举报
回复
不行的话,还有别例
Tadpole0510 2002-03-05
  • 打赏
  • 举报
回复

别人写的一个函数,返回汉字字符串第一个汉字拼音的第一个字母,对你或许会有些帮助。



'******自定义函数,对任意输入的汉字,可以得到它的拼音的第一个字母********
'//函数入口为汉字串,返回值为该汉字的第一个字母
Public Function getHzPy(hzStr As String) As String
On Error Resume Next
'declare variable
Dim myHzm As Integer
Dim qm As Integer
Dim wm As Integer
Dim hznm As String
If Len(hzStr) > 1 Then
myHzm = Asc(Left(hzStr, 1))
Else
myHzm = Asc(hzStr)
End If
If myHzm > = 0 And myHzm < 256 Then
'字母
getHzPy = hzStr
Else
'汉字
qm = (myHzm + 65536) \ 256 '取区码
wm = (myHzm + 65536) Mod 256 '取位码
'十进制到十六进制
hznm = tento(qm, 16) & tento(wm, 16)
End If
If "B0A1" < = hznm And hznm < = "B0C4" Then
getHzPy = "A"
ElseIf "B0C5" < = hznm And hznm < = "B2C0" Then
getHzPy = "B"
ElseIf "B2C1" < = hznm And hznm < = "B4ED" Then
getHzPy = "C"
ElseIf "B4EE" < = hznm And hznm < = "B6E9" Then
getHzPy = "D"
ElseIf "B6EA" < = hznm And hznm < = "B7A1" Then
getHzPy = "E"
ElseIf "B7A2" < = hznm And hznm < = "B8C0" Then
getHzPy = "F"
ElseIf "B8C1" < = hznm And hznm < = "B9FD" Then
getHzPy = "G"
ElseIf "B9FE" < = hznm And hznm < = "BBF6" Then
getHzPy = "H"
ElseIf "BBF7" < = hznm And hznm < = "BFA5" Then
getHzPy = "J"
ElseIf "BFA6" < = hznm And hznm < = "C0AB" Then
getHzPy = "K"
ElseIf "C0AC" < = hznm And hznm < = "C2E7" Then
getHzPy = "L"
ElseIf "C2E8" < = hznm And hznm < = "C4C2" Then
getHzPy = "M"
ElseIf "C4C3" < = hznm And hznm < = "C5B5" Then
getHzPy = "N"
ElseIf "C5B6" < = hznm And hznm < = "C5BD" Then
getHzPy = "O"
ElseIf "C5BE" < = hznm And hznm < = "C6D9" Then
getHzPy = "P"
ElseIf "C6DA" < = hznm And hznm < = "C8BA" Then
getHzPy = "Q"
ElseIf "C8BB" < = hznm And hznm < = "C8F5" Then
getHzPy = "R"
ElseIf "C8F6" < = hznm And hznm < = "CBF9" Then
getHzPy = "S"
ElseIf "CBFA" < = hznm And hznm < = "CDD9" Then
getHzPy = "T"
ElseIf "CDDA" < = hznm And hznm < = "CEF3" Then
getHzPy = "W"
ElseIf "CEF4" < = hznm And hznm < = "D188" Then
getHzPy = "X"
ElseIf "D1B9" < = hznm And hznm < = "D4D0" Then
getHzPy = "Y"
ElseIf "D4D1" < = hznm And hznm < = "D7F9" Then
getHzPy = "Z"
Else
getHzPy = hznm
End If
End Function
'************************辅助函数,可以从十进制转换到任意进制**********************
'//入口为十进制数,要转换的进制,返回为该进制数
Public Function tento(m As Integer, n As Integer) As String
Dim q As Integer
Dim r As Integer
tento = ""
Dim bStr As String
Do
Call myDivide(m, n, q, r)
If r > 9 Then
bStr = Chr(55 + r)
Else
bStr = Str(r)
End If
tento = Trim(bStr) & tento
m = q
Loop While q < > 0
End Function

'************************辅助过程,得到任意两个数的商和余数***************************
Public Sub myDivide(num1 As Integer, num2 As Integer, q As Integer, r As Integer)
If num2 = 0 Then
MsgBox ("非法除数")
Exit Sub
End If
If num1 / num2 > = 0 Then
q = Int(num1 / num2)
Else
q = Int(num1 / num2) + 1
End If
r = num1 Mod num2
End Sub

加分把!!!
syncbiny 2002-03-05
  • 打赏
  • 举报
回复
但是我的字段经常添加,对应表是手工生成的吗?smogei(迷路者) 所说汉字编码怎样做?
jett 2002-03-03
  • 打赏
  • 举报
回复
我知道有很多股票软件实际上是有一个拼音字母与股票代码的对应表
查表来解决
smogei 2002-03-03
  • 打赏
  • 举报
回复
我想可以从汉字编码方法来考虑.
syncbiny 2002-03-03
  • 打赏
  • 举报
回复
我要知道的是通过拼音字母头查汉字字段的方法,不是格式。
shawls 2002-03-03
  • 打赏
  • 举报
回复


关注一下,
yanz 2002-03-03
  • 打赏
  • 举报
回复
使用ComboBox控件即可,设置其Style属性为1-VbComboSimple,向控件中添加列表项;只要在控件上的文本框中输入文字,其上列表框会自动对应输入的内容,就像你所要求的

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧