質問

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

役に立ちましたか?

解決

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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top