declare a string of fixed length

Posted on 2005-04-08
Medium Priority
Last Modified: 2010-08-05
how do you declare a string of fixed length?

Dim myStringVar as String _____

Question by:brokeMyLegBiking

Expert Comment

ID: 13737979
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.
LVL 32

Expert Comment

ID: 13738107
<VBFixedString(15)> Private YourStringName As String
LVL 32

Expert Comment

ID: 13738173
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 13738250
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?

LVL 13

Expert Comment

by:Corey Scheich
ID: 13738290
Check this PAQ

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

LVL 13

Accepted Solution

Corey Scheich earned 1800 total points
ID: 13738297

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question