From: Phil Hunt on
Hi
I am trying to "map" a string into many fixed length fields so I don't have
to use substr repetively. I thought I could use Structure, but it does not
allow fix length field. Can you suggest a way to do this sort of thing ?


From: Scott M. on

"Phil Hunt" <aaa(a)aaa.com> wrote in message
news:exk32R$VKHA.3720(a)TK2MSFTNGP02.phx.gbl...
> Hi
> I am trying to "map" a string into many fixed length fields so I don't
> have to use substr repetively. I thought I could use Structure, but it
> does not allow fix length field. Can you suggest a way to do this sort of
> thing ?

Strings are reference types. The Char type is a value type, but it can only
hold one character, unless you made a character array.

What exactly are you trying to accomplish? Since strings are classes, they
have a wide assortment of methods for parsing. The substr function of VB 6
still works, but you really don't need to use it any longer. You can use the
String methods.

If you'll be doing quite a few manipulations, you should look into the
StringBuilder class.

-Scott


From: Phil Hunt on
I still find myself thinking in the old day where you can move a record into
a data structure and the structure will map out the offset and length for
you. It has a great advantage if something change, the offset is auto.

I don't think it has a similar constuct in .net or even VB6. (prob a lot of
work for little gain)

I just do substring then.

"Scott M." <s-mar(a)nospam.nospam> wrote in message
news:u1pV2JAWKHA.4004(a)TK2MSFTNGP05.phx.gbl...
>
> "Phil Hunt" <aaa(a)aaa.com> wrote in message
> news:exk32R$VKHA.3720(a)TK2MSFTNGP02.phx.gbl...
>> Hi
>> I am trying to "map" a string into many fixed length fields so I don't
>> have to use substr repetively. I thought I could use Structure, but it
>> does not allow fix length field. Can you suggest a way to do this sort of
>> thing ?
>
> Strings are reference types. The Char type is a value type, but it can
> only hold one character, unless you made a character array.
>
> What exactly are you trying to accomplish? Since strings are classes,
> they have a wide assortment of methods for parsing. The substr function
> of VB 6 still works, but you really don't need to use it any longer. You
> can use the String methods.
>
> If you'll be doing quite a few manipulations, you should look into the
> StringBuilder class.
>
> -Scott
>


From: Tom Shelton on
On 2009-10-28, Phil Hunt <aaa(a)aaa.com> wrote:
> I still find myself thinking in the old day where you can move a record into
> a data structure and the structure will map out the offset and length for
> you. It has a great advantage if something change, the offset is auto.
>
> I don't think it has a similar constuct in .net or even VB6. (prob a lot of
> work for little gain)
>
> I just do substring then.

I generally approach this with a class that understands the record layout, and
then parses into individual fields that can be accessed either by index, name,
or properties depending on the type of file...

--
Tom Shelton
From: James Hahn on
Why not use ordinary strings? What is the feature of a fixed length string
that is important to this procedure, or what part of the procedure won't
work properly with variable length strings?

"Phil Hunt" <aaa(a)aaa.com> wrote in message
news:exk32R$VKHA.3720(a)TK2MSFTNGP02.phx.gbl...
> Hi
> I am trying to "map" a string into many fixed length fields so I don't
> have to use substr repetively. I thought I could use Structure, but it
> does not allow fix length field. Can you suggest a way to do this sort of
> thing ?
>

 | 
Pages: 1
Prev: Hashtable or Datatable?
Next: ftp in vb.net