
Help - Simply Getting Data from Extrenal Data Files (not from Access Data Base)
Well, I don't know much about VB.net, and I hate to say it, but maybe you
should start learning C++/C# to access files randomly. I hear you can mix
programming languages in VS.net, so you can write your file access routines
in C and your data manipulation routines in VB?
Another idea ...
Public Type TestType
Field1 as String
Field2 as String
End Type
Public TestRec as TestType
TestRec.Field1 = Space$(2)
'you get the gist...
Will that work?
Quote:
> Open "TEST.DAT" For Random As #1 Len = Len(TestRec)
Try LenB instead of Len?
Sorry if any of these suggestions are worthless, I've only been using Basic
for < 2 years.
--
Scott Shell
Please post replies both to the newsgroup and to my email address,
Quote:
> My question has to do with getting data from files. I have always used
> random access fixed record length files. Is Microsoft forcing people to
> store their data in Access Data base (or some other data base files)? To
> use random access files, all you have to do is define a fixed-length
record
> structure ("user defined type") and then open the file in RANDOM mode.
But,
> to define a fixed-length record structure, naturally you have to use fixed
> length strings. The new VB.NET version does not allow fixed strings in
the
> user define types.
> I looked at the ADO approach to data retrieval, but it involves so much
more
> overhead compared to just defining a record structure and then opening the
> file in random mode. Plus it only works on ASCII text files in sequential
> mode (as opposed to random accessed binary files). Which is ludicrous.
The
> example they show of maintaining an ASCII file using ADO requires you to
> read the entire file into memory. Then add or modify records and then
> delete the file and write the whole thing out again!
> Do you have any thoughts or insights on this subject?
> Gratefully,
> Joe
> ************************************************************************
> P.S.
> I sent the following message to Microsoft, but have not received an
answer:
> First of all, I love VB and have used it and other forms of Basic for over
> twenty years. I am very concerned about the loss of fixed strings in the
> new VB.NET version. How else can you define a data type (structure) when
> you are describing a fixed format record for random access file i/o? I
have
> tried the recommended steps in the document announcing VB.Net, but it did
> not work. It generated an error msg: "Bad Record Length" Please advise.
> An example would be:
> Public Type TestType
> Field1 as String * 2
> Field2 as String * 10
> End Type
> Public TestRec as TestType
> Open "TEST.DAT" For Random As #1 Len = Len(TestRec)
> Put #1,1,TestRec
> .
> .
> .