Link to home
Start Free TrialLog in
Avatar of brokeMyLegBiking
brokeMyLegBiking

asked on

declare a string of fixed length

how do you declare a string of fixed length?

Dim myStringVar as String _____

Avatar of jong3
jong3

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
Avatar of brokeMyLegBiking

ASKER

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?


Check this PAQ

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

Corey2
ASKER CERTIFIED SOLUTION
Avatar of Corey Scheich
Corey Scheich
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial