[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB 2005 fixed length fields

Posted on 2006-05-26
3
Medium Priority
?
369 Views
Last Modified: 2012-06-27
I need to pass a string of fixed length fields to an AS400 from my Visual Studio 2005 / Visual Basic program.

Dim strFieldName as string * 18         receives an error for the "* 18" in 2005 VB.

How do I define a string field in VB 2005 with a fixed length value of 18?
0
Comment
Question by:RussBurns
  • 2
3 Comments
 
LVL 7

Expert Comment

by:davidrichardson
ID: 16771450
.NET does NOT support Fixed length strings.

From the help file

"Note   The VBFixedStringAttribute is informational and cannot be used to convert a variable length string to a fixed string. The purpose of this attribute is to modify how strings in structures and non-local variables are used by methods or API calls that recognize the VBFixedStringAttribute. Keep in mind that this attribute does not change the actual length of the string itself."


0
 
LVL 7

Expert Comment

by:davidrichardson
ID: 16771457
0
 
LVL 44

Accepted Solution

by:
bruintje earned 2000 total points
ID: 16771651
Hi RussBurns,
----------

in addition you could use the stringbuilder class but even when declaring the capacity it will expand when you insert larger strings then 18 but it will be fixed length so if you need 18 spaces

      Dim sb As New StringBuilder(8)
      sb.Insert(0, "this") ' < the sb will be 8 in length
      sb.Insert(0, "this is a test") ' the sb will be 14 in length


you can also pad a string like
      s.PadRight(18," ")

but again this string will be 24 in length if you put in a string larger then 18
----------
bruintje
share what you know, learn what you don't
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 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