您的位置:程序门 -> vb -> 基础类



大家好,我是个初学者,问个问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


大家好,我是个初学者,问个问题
发表于:2008-01-11 10:50:29 楼主
两个文本框(text1,text2),一个按钮(cmd1),实现当text1输入内容时,text2能显示出输入的长度,
这个要怎么做?最好能有详细代码,谢谢
发表于:2008-01-11 10:51:451楼 得分:0
text2能显示出输入的长度,   还要判断是字符,数字还是汉字
发表于:2008-01-11 10:52:312楼 得分:0
vbscript code
private sub command1_click() text2.text=len(text1.text) 'len函數用來判斷括號內部 string 的字數。 end sub
发表于:2008-01-11 10:54:443楼 得分:0
vbscript code
inputstr = "" if asc(inputstr) < 0 then gbascii = ascb(strconv(inputstr, vbfromunicode)) '区位码在16区之后的为汉字 if gbascii - 160 > 15 then print "是汉字" else print "是全角符号" end if else print "是半角英文或数字" end if
发表于:2008-01-11 11:37:394楼 得分:0
private   sub   text1_keyup(keycode   as   integer,   shift   as   integer)
        dim   i   as   integer,   c   as   integer
        for   i   =   1   to   len(text1)
                c   =   c   +   iif(asc(mid(text1,   i,   1))   <   0,   2,   1)
        next   i
        text2   =   c
end   sub
发表于:2008-01-11 11:40:475楼 得分:0
一个汉字占两个字节长度
private   sub   text1_keyup(keycode   as   integer,   shift   as   integer)
        dim   i   as   integer,   c   as   integer
        c   =   0
        for   i   =   1   to   len(text1)
                c   =   c   +   iif(asc(mid(text1,   i,   1))   <   0,   2,   1)
        next   i
        text2   =   c
end   sub

一个汉字算一个字节长度时
private   sub   text1_keyup(keycode   as   integer,   shift   as   integer)
        text2   =   len(text1)
end   sub
发表于:2008-01-11 12:03:026楼 得分:0
同意三楼的,,,这个应该比较全了


快速检索

最新资讯
热门点击