Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / August 2006

Tip: Looking for answers? Try searching our database.

Update a structure when another structure changes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thelonious Monk - 06 Aug 2006 17:47 GMT
Is there a way to update two structures when you use a FileGet to read a
record?  For example:

       Public Structure MyRecordStructure
           <VBFixedString(517)> Dim All_Of_Record as String
       End Structure

       Public Structure Record1_Structure
           <VBFixedString(1)> Dim Record_Type as String
           <VBFixedString(30)> Dim CustomerName as String
           <VBFixedString(486)> Dim Rest_Of_Record as String
       End Structure

       Public Structure Record2_Structure
           <VBFixedString(1)> Dim Record_Type as String
           <VBFixedString(8)> Dim CustomerNumber as String
           <VBFixedString(30)>Dim CustomerAddress as String
           <VBFixedString(478)> Dim Rest_Of_Record as String
       End Structure
                               .
                               .
                               .
                               .
       Dim MyInputRecord as MyRecordStructure
       Dim Record_Type1 as Record1_Structure
       Dim Record_Type2 as Record2_Structure

                               .
                               .
                               .
       InputCh = FreeFile
       FileOpen(InputCh, "c:\this\is\my\file", OpenMode.Random,
OpenAccess.Default, OpenShare.Shared, 517)
       Do While Not EOF(InputCh)
           FileGet(InputCh, MyInputRecord)
           '
           '    Map the contents of MyInputRecord to Record_Type1 and
Record_Type2
           '
                               .
                               .
                               .
       End While

The FileGet method reads information into a structure that you have
declared.  What I'm trying to accomplish is an automatic mapping of one
record structure (MyInputRecord) to Record_Type1 and Record_Type2, similar
to how languages such as COBOL does it.  Each record in my file is 517
characters in length without any termination in the record (i.e.  no
CHR(13)).  Can someone offer any useful suggestions?

Thanks!
tomb - 06 Aug 2006 19:10 GMT
>Is there a way to update two structures when you use a FileGet to read a
>record?  For example:
[quoted text clipped - 50 lines]
>
>  

mid(str1,start,length)

T
Thelonious Monk - 06 Aug 2006 20:04 GMT
> mid(str1,start,length)
>
> T

I would have to write a Mid statement for each field.  I have a bunch.  I
would like the process to be done automatically, if possible.
GhostInAK - 06 Aug 2006 23:32 GMT
Hello Thelonious,

Since, as you say, you have fixed-length records.. how about just one structure..
The one that has the most level of detail.
Then you can add properties and/or methods for accessing the data in any
way you choose.  You might even create your other structures (if you really
have need of them) and provide conversion functions off the main struct..
like MainStruct.ToSomeOtherStruct().. which would provide a copy of the data
in a diff format.

-Bo

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.