if keyascii > = -20319 and keyascii <= -3652 or keyascii = 8 then else keyascii = 0 end if
end sub
我是这样做的 但在中文输入法下一样可以输入数字和字母 我应该怎么做才能让它只输入汉字?
发表于:2007-06-29 08:00:371楼 得分:0
private sub text1_validate(cancel as boolean) if len(text1.text) * 2 <> lenb(strconv(text1.text, vbfromunicode)) then msgbox "please input chinese characters " cancel = true end if end sub
发表于:2007-06-29 08:17:122楼 得分:0
你是说连全角数字和字母也禁止? private sub potext_keypress(keyascii as integer)
if keyascii > 0 then keyascii = 0
select case keyascii case -23632 to -23623, -23615 to -23590,-23583 to -23558 keyascii = 0 end select
end sub
发表于:2007-06-29 09:09:083楼 得分:0
学习一下
发表于:2007-06-29 10:31:144楼 得分:0
正则:
option explicit
'引用 microsoft vbscript regular expressions dim stext as string
function bmatching(s as string, p as string) as boolean '参数:s要匹配的字符串,p正则表达式 on error goto 100 dim myreg as regexp set myreg = new regexp
bmatching = false myreg.ignorecase = true myreg.pattern = p bmatching = myreg.test(s) exit function 100: bmatching = false end function
private sub text2_change() dim p as string p = "^[\u4e00-\u9fa5]{0,}$ " if bmatching(text2, p) then stext = text2 else text2 = stext text2.selstart = len(text2) end if end sub
发表于:2007-06-29 10:48:325楼 得分:0
to of123 是的,我想把全角的数字和字母也禁止 现在还是不行 有没有办法?
发表于:2007-06-29 11:32:526楼 得分:0
private sub text1_change() dim i as long for i = 0 to 25 text1.text = replace(text1.text, chr(i + 65), " ", , , vbtextcompare) next end sub