Input box limit in VB

折月煮酒 提交于 2019-12-24 12:19:19

问题


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.

Like the textBoxes have a MaxLength, is there a way to set a similar restriction to an inputBox?

Thanks


回答1:


Little easier than creating a custom class...

Instead why not create a temporary string variable and assign it by your input box. . .

then check the count in a do until loop...

EX.

 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


来源:https://stackoverflow.com/questions/20686928/input-box-limit-in-vb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!