|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Random access file helpaccess file. I have tried to convert it to run in vb. The code is: (note ARRAY, FILE$ and FILEEXTENSION$ are variables assigned a value) DIM DM1(ARRAY), NL1(ARRAY), LP1(ARRAY), CP1(ARRAY), PS1(ARRAY), RA1(ARRAY), CR1(ARRAY) OPEN "R", #1, "A:" + FILE$ + FILEEXTENSION$, 16 FOR I% = 0 TO ARRAY FIELD #1, 4 AS AAA$, 4 AS BBB$, 4 AS CCC$, 4 AS DDD$ GET #1, (I% + 1) DM1(I%) = CVSMBF(AAA$) NL1(I%) = CVSMBF(BBB$) * 1 / 1 LP1(I%) = CVSMBF(CCC$) CP1(I%) = CVSMBF(DDD$) CP1(I%) = CP1(I%) * CPM >From looking on the help and forums I have tried this (below) as a start but I'm really not sure I'm doing the right thing as it displaysloads of random characters when I output it to excel: File = FreeFile Open "filename" For Input As File For i = 0 To 1 Line Input #File, text Next i Close File If anyone could explain how to convert this to run in vb I would be very grateful. Cheers On 1 Mar 2007 00:35:20 -0800, sunny_side_up_2***@yahoo.co.uk wrote:
Show quoteHide quote >I have been given a file in quick basic which reads data from a random The FIELD statement is not supported in VB>access file. I have tried to convert it to run in vb. The code is: >(note ARRAY, FILE$ and FILEEXTENSION$ are variables assigned a value) > > DIM DM1(ARRAY), NL1(ARRAY), LP1(ARRAY), CP1(ARRAY), PS1(ARRAY), >RA1(ARRAY), CR1(ARRAY) >OPEN "R", #1, "A:" + FILE$ + FILEEXTENSION$, 16 >FOR I% = 0 TO ARRAY > FIELD #1, 4 AS AAA$, 4 AS BBB$, 4 AS CCC$, 4 AS DDD$ > GET #1, (I% + 1) > DM1(I%) = CVSMBF(AAA$) > NL1(I%) = CVSMBF(BBB$) * 1 / 1 > LP1(I%) = CVSMBF(CCC$) > CP1(I%) = CVSMBF(DDD$) > CP1(I%) = CP1(I%) * CPM > >>From looking on the help and forums I have tried this (below) as a >start but I'm really not sure I'm doing the right thing as it displays >loads of random characters when I output it to excel: > >File = FreeFile > Open "filename" For Input As File > For i = 0 To 1 > Line Input #File, text > Next i >Close File > >If anyone could explain how to convert this to run in vb I would be >very grateful. You need to set up a UDT Type TREC AAA As Single BBB As Single CCC As Single DDD As Single End Type Dim Rec as TREC Filename$ = "A:" + FILE$ + FILEEXTENSION$ FileNo = FreeFile Open Filename$ For Random Access Read As FileNo Len = 16 For I = 0 To Array Get# FileNo, I + 1, Rec DM1(I%) = Rec.AAA Now the big problem here is CVSMBF() means that the data is stored in Microsoft Binary Format which is not the same as IEEE format You really need to run up a little QBasic App to read the data and write it out in IEEE format eg: LSET AAA$ = MKS$( CVSMBF(AAA$) ) Incidentally the person who wrote that code was not a good programmer, the FIELD statement only needs to be done once, not repeatedly. sunny_side_up_2***@yahoo.co.uk wrote:
Show quoteHide quote > I have been given a file in quick basic which reads data from a random Once you follow Jerry's advice to get the data into the program, you can use our free DLL to convert the MBF values to IEEE values. Find it as MBFIEE32.ZIP on our web site under "Products".> access file. I have tried to convert it to run in vb. The code is: > (note ARRAY, FILE$ and FILEEXTENSION$ are variables assigned a value) > > DIM DM1(ARRAY), NL1(ARRAY), LP1(ARRAY), CP1(ARRAY), PS1(ARRAY), > RA1(ARRAY), CR1(ARRAY) > OPEN "R", #1, "A:" + FILE$ + FILEEXTENSION$, 16 > FOR I% = 0 TO ARRAY > FIELD #1, 4 AS AAA$, 4 AS BBB$, 4 AS CCC$, 4 AS DDD$ > GET #1, (I% + 1) > DM1(I%) = CVSMBF(AAA$) > NL1(I%) = CVSMBF(BBB$) * 1 / 1 > LP1(I%) = CVSMBF(CCC$) > CP1(I%) = CVSMBF(DDD$) > CP1(I%) = CP1(I%) * CPM >
Other interesting topics
OT - MS: $4,000 for Daylight Saving Fix
Within a *.exe Function that returns an Array Reason for 'Set' keyword Source Control via Network Drive Looking for a way to call LogOff and Shutdown. Cannot quit Excel called from VB6 Getting Info from a .TTF File Sin, Cos Centering a datagrid's column headers |
|||||||||||||||||||||||