有关输入的问题,在线等待

zhenglou 2003-08-21 10:42:50
本人在做开发过程中,碰到用户提到如下需求:输入企业名称的拼音代码,弹出企业名称的列表。。现在表已经建好了,但是没什么思路。。不知道哪位大大有这方面代码或者控件,,,谢谢了先啊 。。。
...全文
82 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hxy2003 2003-08-21
  • 打赏
  • 举报
回复
不用临时表,就列表框列出来嘛..

哦.楼上的代码很好的啊.
yijiansong 2003-08-21
  • 打赏
  • 举报
回复
根据 “拼音码” 查询后列表
diki 2003-08-21
  • 打赏
  • 举报
回复
你是说一个拼音对应几个公司的情况吗,那样的话全部找到后列出来不就行了,建个临时表放查询结果
zhenglou 2003-08-21
  • 打赏
  • 举报
回复
谢谢楼上的几位大大,我的思路和碰到的问题是这样的,企业表里面添加一个字段:拼音码,用户可以进行手工维护。然后再其他页面中需要输入企业名称的时候,用户直接输入拼音代码就可以弹出列表,并不是楼上所说的拼音转化。现在我就是对输入拼音代码弹出企业列表没有思路。
dandy1437 2003-08-21
  • 打赏
  • 举报
回复
或者看到别人的一个方法
“控制面板”->“添加/删除程序”->“Windows安装程序”->“附件”->“输入法生成器”



打开 输入法生成器,切换到“逆转换”->“打开文件(O)”->“C:\Windows\System\winpy.mb”->“确定”关闭打开对话框->设置好路径,点击“逆转换”按键

dandy1437 2003-08-21
  • 打赏
  • 举报
回复
'用于实现汉子与拼音转换的类模块



Private Const IME_ESC_MAX_KEY = &H1005

Private Const IME_ESC_IME_NAME = &H1006

Private Const GCL_REVERSECONVERSION = &H2



Private Type CANDIDATELIST

dwSize As Long

dwStyle As Long

dwCount As Long

dwSelection As Long

dwPageStart As Long

dwPageSize As Long

dwOffset(1) As Long

End Type



Private Declare Function GetKeyboardLayoutList Lib "user32" (ByVal nBuff As Long, lpList As Long) As Long

Private Declare Function ImmEscape Lib "imm32.dll" Alias "ImmEscapeA" (ByVal hkl As Long, ByVal himc As Long, ByVal un As Long, lpv As Any) As Long

Private Declare Function ImmGetConversionList Lib "imm32.dll" Alias "ImmGetConversionListA" (ByVal hkl As Long, ByVal himc As Long, ByVal lpsz As String, lpCandidateList As Any, ByVal dwBufLen As Long, ByVal uFlag As Long) As Long

Private Declare Function IsDBCSLeadByte Lib "kernel32" (ByVal bTestChar As Byte) As Long



Private Const NUM_OF_BUFFERS = 40

Private Const MSPY = "微软拼音输入法"

Dim imeHandle(1 To NUM_OF_BUFFERS) As Long

Dim imeName(1 To NUM_OF_BUFFERS) As String



Dim mlMSPYIndex As Long

Dim imeCount As Long



Private Sub Init()

Dim i As Long

Dim sName As String



mlMSPYIndex = 0

imeCount = GetKeyboardLayoutList(NUM_OF_BUFFERS, imeHandle(1))

If imeCount Then

For i = 1 To imeCount

sName = String(255, " ")

If ImmEscape(imeHandle(i), 0, IME_ESC_IME_NAME, ByVal sName) Then

If sName <> "" Then sName = Left(sName, InStr(sName, vbNullChar) - 1)

imeName(i) = sName

If sName = MSPY Then

mlMSPYIndex = i

End If

End If

Next i

End If



End Sub



Public Property Get MSPYInstalled() As Boolean

MSPYInstalled = IIf(mlMSPYIndex, True, False)

End Property



Public Property Get MSPYIndex() As Long

MSPYIndex = mlMSPYIndex

End Property



Public Property Get Count() As Long

Count = imeCount

End Property



Public Function GetHandle(ByVal lIndex As Long) As Long

If lIndex >= 1 And lIndex <= imeCount Then

GetHandle = imeHandle(lIndex)

End If

End Function



Public Function GetName(ByVal lIndex As Long) As String

If lIndex >= 1 And lIndex <= imeCount Then

GetName = imeName(lIndex)

End If

End Function



Public Function MSPYReverse(ByVal sString As String) As String

Dim lStrLen As Long

Dim i As Long

Dim sChar As String

Dim bChar() As Byte



If MSPYInstalled Then

lStrLen = Len(sString)

MSPYReverse = ""

If lStrLen Then

For i = 1 To lStrLen

sChar = Mid(sString, i, 1)

bChar = StrConv(sChar, vbFromUnicode)

If IsDBCSLeadByte(bChar(0)) Then

Dim lMaxKey As Long

Dim lGCL As Long



lMaxKey = ImmEscape(imeHandle(mlMSPYIndex), 0, IME_ESC_MAX_KEY, Null)

If lMaxKey Then

Dim tCandi As CANDIDATELIST

lGCL = ImmGetConversionList(imeHandle(mlMSPYIndex), 0, sChar, 0, 0, GCL_REVERSECONVERSION)

If lGCL > 0 Then

Dim bBuffer() As Byte

Dim MaxKey As Long

Dim sBuffer As String

sBuffer = String(255, vbNullChar)

MaxKey = lMaxKey

lGCL = ImmGetConversionList(imeHandle(mlMSPYIndex), 0, sChar, ByVal sBuffer, lGCL, GCL_REVERSECONVERSION)

If lGCL > 0 Then

Dim bPY() As Byte

Dim j As Long



bBuffer = StrConv(sBuffer, vbFromUnicode)



ReDim bPY(MaxKey * 2 - 1)

For j = bBuffer(24) To bBuffer(24) + MaxKey * 2 - 1

bPY(j - bBuffer(24)) = bBuffer(j)

Next j

sChar = StrConv(bPY, vbUnicode)



If InStr(sChar, vbNullChar) Then

sChar = Trim(Left(sChar, InStr(sChar, vbNullChar) - 1))

End If

sChar = Left(sChar, Len(sChar) - 1) & " "

End If

End If

End If

End If

MSPYReverse = MSPYReverse & sChar

Next i

End If

Else

'替代方法

MSPYReverse = GetPYStr(sString)

End If

End Function



Private Sub Class_Initialize()

Init

End Sub



Private Function GetPYChar(a1 As String) As String

Dim t1 As String

If Asc(a1) < 0 Then

t1 = Left(a1, 1)

If Asc(t1) < Asc("啊") Then

GetPYChar = " "

Exit Function

End If

If Asc(t1) >= Asc("啊") And Asc(t1) < Asc("芭") Then

GetPYChar = "A"

Exit Function

End If

If Asc(t1) >= Asc("芭") And Asc(t1) < Asc("擦") Then

GetPYChar = "B"

Exit Function

End If

If Asc(t1) >= Asc("擦") And Asc(t1) < Asc("搭") Then

GetPYChar = "C"

Exit Function

End If

If Asc(t1) >= Asc("搭") And Asc(t1) < Asc("蛾") Then

GetPYChar = "D"

Exit Function

End If

If Asc(t1) >= Asc("蛾") And Asc(t1) < Asc("发") Then

GetPYChar = "E"

Exit Function

End If

If Asc(t1) >= Asc("发") And Asc(t1) < Asc("噶") Then

GetPYChar = "F"

Exit Function

End If

If Asc(t1) >= Asc("噶") And Asc(t1) < Asc("哈") Then

GetPYChar = "G"

Exit Function

End If

If Asc(t1) >= Asc("哈") And Asc(t1) < Asc("击") Then

GetPYChar = "H"

Exit Function

End If

If Asc(t1) >= Asc("击") And Asc(t1) < Asc("喀") Then

GetPYChar = "J"

Exit Function

End If

If Asc(t1) >= Asc("喀") And Asc(t1) < Asc("垃") Then

GetPYChar = "K"

Exit Function

End If

If Asc(t1) >= Asc("垃") And Asc(t1) < Asc("妈") Then

GetPYChar = "L"

Exit Function

End If

If Asc(t1) >= Asc("妈") And Asc(t1) < Asc("拿") Then

GetPYChar = "M"

Exit Function

End If

If Asc(t1) >= Asc("拿") And Asc(t1) < Asc("哦") Then

GetPYChar = "N"

Exit Function

End If

If Asc(t1) >= Asc("哦") And Asc(t1) < Asc("啪") Then

GetPYChar = "O"

Exit Function

End If

If Asc(t1) >= Asc("啪") And Asc(t1) < Asc("期") Then

GetPYChar = "P"

Exit Function

End If

If Asc(t1) >= Asc("期") And Asc(t1) < Asc("然") Then

GetPYChar = "Q"

Exit Function

End If

If Asc(t1) >= Asc("然") And Asc(t1) < Asc("撒") Then

GetPYChar = "R"

Exit Function

End If

If Asc(t1) >= Asc("撒") And Asc(t1) < Asc("塌") Then

GetPYChar = "S"

Exit Function

End If

If Asc(t1) >= Asc("塌") And Asc(t1) < Asc("挖") Then

GetPYChar = "T"

Exit Function

End If

If Asc(t1) >= Asc("挖") And Asc(t1) < Asc("昔") Then

GetPYChar = "W"

Exit Function

End If

If Asc(t1) >= Asc("昔") And Asc(t1) < Asc("压") Then

GetPYChar = "X"

Exit Function

End If

If Asc(t1) >= Asc("压") And Asc(t1) < Asc("匝") Then

GetPYChar = "Y"

Exit Function

End If

If Asc(t1) >= Asc("匝") Then

GetPYChar = "Z"

Exit Function

End If

Else

If UCase(a1) <= "Z" And UCase(a1) >= "A" Then

GetPYChar = UCase(Left(a1, 1))

Else

GetPYChar = " "

End If

End If

End Function



Private Function GetPYStr(ByVal S As String) As String

Dim l As Long

Dim sOut As String



If S <> "" Then

For l = 1 To Len(S)

sOut = sOut & GetPYChar(Mid(S, l, 1))

Next l

GetPYStr = sOut

End If

End Function



dandy1437 2003-08-21
  • 打赏
  • 举报
回复
你可以把企业名称的拼音代码作为数据的关键字,通过查询匹配出(弹出企业名称的列表)

7,759

社区成员

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

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