VB中编写密码程序,怎样设置使得文本框输入字符
发布网友
发布时间:2022-05-20 11:22
我来回答
共1个回答
热心网友
时间:2023-10-17 14:44
例如因为你输入大写时,触发
text_change
事件,会改为小写,而这样又会触发
change
事件,又把小写改为大写,这样就是死循环,导致溢出
可以定义一个变量保存当前状态,当改变一次就就不再执行,直到有键盘或者鼠标输入时恢复
dim
b
as
boolean
private
sub
t1_change()
if
b
then
b
=
false
t1.selstart
=
len(t1.text)
a
=
right(t1.text,
1)
if
asc(a)
>=
65
and
asc(a)
<=
90
then
t1.text
=
mid$(t1.text,
1,
len(t1.text)
-
1)
+
lcase(a)
elseif
asc(a)
>=
97
and
asc(a)
<=
122
then
t1.text
=
mid$(t1.text,
1,
len(t1.text)
-
1)
+
ucase(a)
elseif
asc(a)
=
32
then
t1.text
=
mid$(t1.text,
1,
len(t1.text)
-
1)
+
a
else
t1.text
=
mid$(t1.text,
1,
len(t1.text)
-
1)
+
"*"
end
if
end
if
end
sub
private
sub
t1_keydown(keycode
as
integer,
shift
as
integer)
b
=
true
end
sub
private
sub
t1_mouse迹袱管惶攮耗归同害括down(button
as
integer,
shift
as
integer,
x
as
single,
y
as
single)
b
=
true
end
sub