Reading Random Files?
Reading Random Files?
Reading Random Files?
Reading Random Files?
Reading Random Files?
Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files?
Reading Random Files? Reading Random Files?
Reading Random Files?
Go Back  Xtreme Visual Basic Talk > > > Reading Random Files?


Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2005, 07:24 PM
QB45 QB45 is offline
Newcomer
 
Join Date: Nov 2004
Posts: 7
Question Reading Random Files?


I have a random file that was created in QuickBasic 4.5 that I'm now trying to read using VB.n ...

The relative file has 8 fixed length fields, with a record length of 318.

In Visual Basic I created a Public Structure (named Toys) with eight VBFixedString variables, defining each of those variables as a public string.


Code:
Public Structure Toys
    <VBFixedString(2)> Public DCAT as String
    <VBFixedString(2)> Public DMFG as String
    <VBFixedString(275)> Public DDesc as String
    <VBFixedString(7)> Public DID as String
    <VBFixedString(8)> Public DLMC as String
    <VBFixedString(8)> Public DLWP as String
    <VBFixedString(8)> Public DMIP as String
    <VBFixedString(8)> Public DMISP as String
End Structure
In a public class I defined AlphaRec as an integer and Collection as Toys


Code:
Public AlphaRec as Integer, Collection as Toys
In a private sub I have writen:


Code:
DIM Alpha as Integer, Cat as String, Mfg as String

-snip-

FileOpen(1, "C:\SWC_WEB\DATA.LIB", OpenMode.Random, , , 318)
cboDescription.BeginUpdate()
Alpha = AlphaRec - 1
DO
     Alpha = Alpha + 1
     FileGet(1, Collection, Alpha)
     If Cat = Dcat and Mfg = DMfg then cboDescription.Items.Add(DDesc) : X = 1
Loop until (Cat <> Dcat and X=1) or EOF(1)
cboDescription.EndUpdate()
FileClose(1)
Earlier in the sub I have Cat and Mfg set as two character pairs that occur in the DCat and DMfg fields of the DATA.LIB file.

Data.lib is a relative file that contains 43,585 records, presorted alphabetically by the DCat and DMfg fields.

AlphaRec is the very first record where DCat and DMfg have any chance at all to match, which is why Cat <> Dcat ends the loop. AlphaRec is the first record where Cat = DCat, so once they no longer match, there's no need to read any further.

Every record combination of DCat and DMfg in DATA.LIB has a minimum of 5 matches.

No matter how I try to read this file, I cannot get DDesc to ever equal anything other then null. This was a functioning program in QB45 that I'm now re-writing in VB.n ... I'm new to VB.n so please be gentle if I've missed a concept.

msdn is about as much fun for newbies as whacking myself in the head with a pair of dirty socks. I've re-read their 9 entries several times which is how I've made it this far.

A correction to my code or a link to a completed program I can follow the flow on would be much appreciated!

Thanks!

GtC
Reply With Quote
  #2  
Old 01-18-2005, 11:04 PM
sgt_pinky's Avatar
sgt_pinky sgt_pinky is offline
Contributor
 
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 633
Default

I cannot see in that code you have where you have set DDesc to any value!
Reply With Quote
  #3  
Old 01-18-2005, 11:35 PM
QB45 QB45 is offline
Newcomer
 
Join Date: Nov 2004
Posts: 7
Default

Quote:
Originally Posted by sgt_pinky
I cannot see in that code you have where you have set DDesc to any value!
It's part of the structure "Toys" I've built into the variable to read out of the random file.

I'm believing that if I created a structure of "Toys" and then set Collection as Toys and FileGet'ed Collection from a record, the structure variables should assume the values of the fields of the structure I'm getting.

Is that wrong?

GtC
Reply With Quote
  #4  
Old 01-20-2005, 02:17 PM
QB45 QB45 is offline
Newcomer
 
Join Date: Nov 2004
Posts: 7
Exclamation

Never mind. After 2 days I found a way out. I loaded up Quickbasic, read the random file out a a comma delimited file, started up VB.N and read the comma delimited file into a VB.N random file.

Apparently some quirky bit-level thing makes QB random files incompatible with the VB.N random file input. The new VB.N random file works great wihtout having to modify the source code I posted above.

GtC
Reply With Quote
  #5  
Old 01-21-2005, 01:33 AM
sgt_pinky's Avatar
sgt_pinky sgt_pinky is offline
Contributor
 
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 633
Default

Ok, good one. Yeah, I am no expert on Random Files, sorry couldn't help you out more.

Although, I did start programming with QB 4.5, hehe. Them were the days....
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Reading Random Files?
Reading Random Files?
Reading Random Files? Reading Random Files?
Reading Random Files?
Reading Random Files?
Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files? Reading Random Files?
Reading Random Files?
Reading Random Files?
 
Reading Random Files?
Reading Random Files?
 
-->