Click to See Complete Forum and Search --> : Check Number of Characters


ryanbutler
09-29-2007, 12:40 PM
Hi,

How do you check a certain number of characters in VB.NET? What I mean is say you create an instance of a class Boat where an attribute stateRegistrationNo can only have 10 characters, how do you check for that in an accessor method?

Do you declare a variable:

Dim aString as String={"10"}

Or would you create a string array and loop through checking the Length element?

Thanks for any tips,

ryanbutler
09-29-2007, 02:30 PM
Believe I figured it out...

if(someVariable.Length < 7) Then

'do something

else

'do something else

End If

Cstick
09-30-2007, 12:31 AM
Yep and don't forget that blank space are included in the length. Might use someVariable.Trim.Length <> 10.