在onkeypress事件中添加代码,
当字符不为你所要求的时,令key=char(0),再响玲警告即可了吧

解决方案 »

  1.   

    OnKeyPress??是Delphi的吧,呵呵,VB没有:)是这样,把文本框的IMEMode 属性改一下就行了,改为3 -Disabled例如:
    Text1.IMEMode = 3   ' Disabled
      

  2.   

    Option Explicit
    Public Declare Function ImmAssociateContext Lib "imm32.dll" (ByVal hwnd As Long, ByVal himc As Long) As Long
    Public Declare Function ImmSetOpenStatus Lib "imm32.dll" (ByVal himc As Long, ByVal b As Long) As LongPublic Function SetImeStatus(lHwnd As Long, intStatus As Integer) As Long
    '设置输入法开或关
    '用法:SetImeStatus Text2.hwnd, 1                  SetImeStatus Text2.hwnd, 0Dim L As Long
    L = ImmAssociateContext(lHwnd, intStatus)
    SetImeStatus = L
    If intStatus = 1 Then
        ImmSetOpenStatus L, 1
    End If
    End Function
      

  3.   

    若您希望某文本框中能屏蔽中文,可在该文本框的"keypress"事件中加入下面代码即可:
        if keyascii>255 then '为双字节(如中文)
             keyascii=0
        end if