如何设置文本框输入长度 [英] How to set a textbox input length
本文介绍了如何设置文本框输入长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 VB6
在我的表单中使用文本框.
using Textbox in my form.
我想限制文本框中的输入,所以最大值应该是6.
用户最多应输入六个字符,否则应显示错误消息
I want to limit the Input in the textbox, so maximum value should be 6.
User should enter up to six chars otherwise it should show error message
Button1.click
if Length(textbox1.text) > 6 then
enter only six chars
else if Length(textbox1.text) < 6 then
enter up to six chars
我如何制作上述条件的代码.
How do I make the code for the above condition.
推荐答案
好吧,你离我很近了!
首先...使用 Len
函数,而不是 Length
,后者不存在.
First ... use the Len
function, not Length
, which doesn't exist.
第二...你可以使用函数MsgBox
来显示错误信息.
Second ... you can use the function MsgBox
to display an error message.
综合起来:
If Len(TextBox1.Text) < 6 Then
MsgBox "Too short!"
Else If Len(TextBox1.Text) > 6 Then
MsgBox "Too long!"
End If
这篇关于如何设置文本框输入长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文