VB中的输入框限制 [英] Input box limit in VB
本文介绍了VB中的输入框限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一个简单的问题:我可以在 vb 中通过输入框设置输入的限制吗?
a simple question: can I set the limit for an input through an input box in vb?
当用户插入大于数据库对应字段的字符串时,这显然是一个问题.
When the user inserts a string larger than the database corresponding field, that's a problem obviously.
就像 textBoxes 有 MaxLength 一样,有没有办法为 inputBox 设置类似的限制?
Like the textBoxes have a MaxLength, is there a way to set a similar restriction to an inputBox?
谢谢
推荐答案
比创建自定义类更容易...
Little easier than creating a custom class...
相反,为什么不创建一个临时字符串变量并通过您的输入框分配它...
Instead why not create a temporary string variable and assign it by your input box. . .
然后在 do until 循环中检查计数...
then check the count in a do until loop...
前.
Dim str As String = InputBox("Name", [Title]:="name", [XPos]:=50, [YPos]:=50)
Do Until str.Count() > 0 And str.Count() < 8
MessageBox.Show("I am sorry but you need to input between 1 and 7 characters")
str = InputBox("Name", [Title]:="name", [XPos]:=50, [YPos]:=50)
Loop
这篇关于VB中的输入框限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文