展开全部
Option Explicit
Private Declare Function GetKeyboardLayoutList Lib "user32" (ByVal nBuff As Long, _
lpList As Long) As Long
Private Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" _
(ByVal pwszKLID As String) As Long
Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long
Private Declare Function ImmGetDescription Lib "imm32.dll" Alias "ImmGetDescriptionA" (ByVal _
hkl As Long, ByVal lpsz As String, ByVal uBufLen As Long) As Long
Private Declare Function ActivateKeyboardLayout Lib "user32" (ByVal hkl As Long, ByVal _
flags As Long) As Long
Const IME_CONFIG_GENERAL = 1
Const KLF_REORDER = &H8
Const KLF_ACTIVATE = &H1
Dim la(1 To 16) As Long
Dim ActIme As Long
Private Sub Timer1_Timer()
ActIme = "134481924" ’这里是英文输入法的码。
ActivateKeyboardLayout ActIme, 1
End Sub
这些代码的意思是始终调用英文输入法。设timer的Interval为200就可以了。这些是vb代码。程序关闭后就可以自己调用输入法了,也不用卸载其他的输入法。
Private Declare Function GetKeyboardLayoutList Lib "user32" (ByVal nBuff As Long, _
lpList As Long) As Long
Private Declare Function GetKeyboardLayoutName Lib "user32" Alias "GetKeyboardLayoutNameA" _
(ByVal pwszKLID As String) As Long
Private Declare Function GetKeyboardLayout Lib "user32" (ByVal dwLayout As Long) As Long
Private Declare Function ImmGetDescription Lib "imm32.dll" Alias "ImmGetDescriptionA" (ByVal _
hkl As Long, ByVal lpsz As String, ByVal uBufLen As Long) As Long
Private Declare Function ActivateKeyboardLayout Lib "user32" (ByVal hkl As Long, ByVal _
flags As Long) As Long
Const IME_CONFIG_GENERAL = 1
Const KLF_REORDER = &H8
Const KLF_ACTIVATE = &H1
Dim la(1 To 16) As Long
Dim ActIme As Long
Private Sub Timer1_Timer()
ActIme = "134481924" ’这里是英文输入法的码。
ActivateKeyboardLayout ActIme, 1
End Sub
这些代码的意思是始终调用英文输入法。设timer的Interval为200就可以了。这些是vb代码。程序关闭后就可以自己调用输入法了,也不用卸载其他的输入法。
展开全部
用正则,如果检测到文本框输入的是中文,则文本框内容设为 空
Private Sub RegCode(ByVal s As String, ByVal p As String)
Dim mh As Match
Dim mhs As MatchCollection
Dim re As RegExp
Set re = New RegExp
re.IgnoreCase = True
re.Pattern = p
're.Global = True
s = Text1.Text
re.Pattern = "[\u4e00-\u9fa5]+"
Set mhs = re.Execute(s)
For Each mh In mhs
Text1.Text = ""
Next
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Call RegCode(s, p)
End Sub
Private Sub RegCode(ByVal s As String, ByVal p As String)
Dim mh As Match
Dim mhs As MatchCollection
Dim re As RegExp
Set re = New RegExp
re.IgnoreCase = True
re.Pattern = p
're.Global = True
s = Text1.Text
re.Pattern = "[\u4e00-\u9fa5]+"
Set mhs = re.Execute(s)
For Each mh In mhs
Text1.Text = ""
Next
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Call RegCode(s, p)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
窗体我还真不知道怎么弄。如果你是用textbox来实现输入的话可以设置其IMEMode属性
追问
当然,我也是只找到textbox才来问
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询