Frage

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

War es hilfreich?

Lösung

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top