?
Solved

declare a string of fixed length

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

Dim myStringVar as String _____

0
Comment
Question by:brokeMyLegBiking
6 Comments
 
LVL 2

Expert Comment

by:jong3
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.
0
 
LVL 32

Expert Comment

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

Expert Comment

by:Erick37
ID: 13738173
0
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.

 
LVL 4

Author Comment

by:brokeMyLegBiking
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?


0
 
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.

Corey2
0
 
LVL 13

Accepted Solution

by:
Corey Scheich earned 1800 total points
ID: 13738297
0

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