declare a string of fixed length

how do you declare a string of fixed length?

Dim myStringVar as String _____

Who is Participating?
A string is a data type, and as far as I know of, you are not able to set a size.
Basically, if you want to specify a exact size, you could create a Char array.

You could also just programatically allow a specific sized string to be entered into the variable.
<VBFixedString(15)> Private YourStringName As String
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

brokeMyLegBikingAuthor Commented:
All the <VBFixedString(15)> does is indicate that the string should be fixed length, it doesn't enforce it.

I would likea a way to force an error to be thrown if the wrong string length is assigned.

jong3, how do I declare a char array and assign values to it?

Corey ScheichDeveloperCommented:
Check this PAQ

I posted an example of how you could create a fixed lenght string class also.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.