Main Page | Report this Page
.NET DotNet Forum Index  »  VB.NET Forum (Visual Basic .NET)  »  Structure ?...
Page 1 of 1    

Structure ?...

Author Message
Phil Hunt...
Posted: Wed Oct 28, 2009 11:31 am
Guest
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 ?
 
Scott M....
Posted: Wed Oct 28, 2009 1:13 pm
Guest
"Phil Hunt" <aaa at (no spam) aaa.com> wrote in message
news:exk32R$VKHA.3720 at (no spam) TK2MSFTNGP02.phx.gbl...
Quote:
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
 
Phil Hunt...
Posted: Wed Oct 28, 2009 1:36 pm
Guest
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 at (no spam) nospam.nospam> wrote in message
news:u1pV2JAWKHA.4004 at (no spam) TK2MSFTNGP05.phx.gbl...
Quote:

"Phil Hunt" <aaa at (no spam) aaa.com> wrote in message
news:exk32R$VKHA.3720 at (no spam) 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
 
Tom Shelton...
Posted: Wed Oct 28, 2009 3:17 pm
Guest
On 2009-10-28, Phil Hunt <aaa at (no spam) aaa.com> wrote:
Quote:
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
 
James Hahn...
Posted: Sun Nov 01, 2009 8:14 pm
Guest
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 at (no spam) aaa.com> wrote in message
news:exk32R$VKHA.3720 at (no spam) TK2MSFTNGP02.phx.gbl...
Quote:
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 ?
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Fri Dec 04, 2009 3:16 am