Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

help parseing data

Begginer
From another EE expert:
Private Sub Command0_Click()

Dim intFilenum As Integer           'watch shows value 1--type interger--always 1
Dim intField As Integer             'watch shows as expected
Dim varArray(0 To 1434) As Variant  'watch shows as expected
intFilenum = FreeFile               'watch shows value 2 --type integer-- always 2
Open "c:\rTemp\aqu0207k\aqu0207.drf" For Input As #intFilenum

Do Until EOF(intFilenum)
  For intField = 0 To 1434
    Input #intFilenum, varArray(intField)
  Next

  'This is where you open your tables or invoke your queries to insert your data

Loop
Close #intFilenum

End Sub
===========================
Doing it this way means that the text fields will be stripped of their quote delimiters
automatically by the Input statement.  I used a zero-origin array for two reasons...
1. it is what the SPLIT() function would produce
2. a recordset's fields collection is zero-based

===========================
I follow some of the code.
What does freefile mean? Why this assignment intFilenum = FreeFile ?
Where are the rows? There should be 70 rows.
0
afreer2
Asked:
afreer2
  • 2
  • 2
  • 2
  • +2
4 Solutions
 
stevbeCommented:
FreeFile is a VBA function that returns a pointer to a file from the OS.

intFilenum is needed later on in the code to point back to file handle in the OS so you can do things like read the text from the file into a variable.

The rows are read in one at a time in ... Input #intFilenum, varArray(intField)

Do Until EOF(intFilenum)

tells the code to loop through all lines (rows) in the file until there are no more so it will work for 70 as well as any other number of rows.

Steve
0
 
nico5038Commented:
>What does freefile mean? Why this assignment intFilenum = FreeFile ?
When opening a file a number (Like #1, #2, etc) is required.
Th eFreeFile will return such a number that's not currently used as re-using a number in use gives an error.

The: Do Until EOF(intFilenum) will loop through all rows, the "For intField = 0 To 1434" will get the individual 1435 fields from the array.

Need more info ?

Nic;o)
0
 
Arthur_WoodCommented:
1)What does freefile mean? Why this assignment intFilenum = FreeFile ?


FreeFile is a built in VB function that returns a pointer to the Next Free FileHandle - an internal value that serves as the pointer to the file that you are working with.  This value is an Integer, and is then used, along with the # to identify the file, in the statements:

Open "c:\rTemp\aqu0207k\aqu0207.drf" For Input As #intFilenum  ' associates the fiilehandle #intFileNum (or in you case #2 with the physical file ("c:\rTemp\aqu0207k\aqu0207.drf") and opens the handle for Input (so you can read from the file)

Do Until EOF(intFilenum)  ' continues reading from the file until an End-of-file (EOF) is reached
  For intField = 0 To 1434
    Input #intFilenum, varArray(intField)  'Inputs from the file identified by #2,
  Next
  '  you will come to these lines ONCE for each record, so you should the save the varArray or it will be over-writen by the next record
Loop


I assume that you have 1435 separate fields in each of your 70 rows?

AW
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
GRayLCommented:
I'm running Access 2000 and it allows a maximum of 255 fields in a table.  If indeed you have 1435 fields per record, you are going to have to generate 6 tables to hold the data.
0
 
afreer2Author Commented:
I will need some time to understand what you all are showing me.

nico5038
Yes but I will ask another question.

Arthur_Wood
This is a csv file that "BRIS.com" puts out;they put 7-8 tables in one row(which is a horses history along with "todays race"
There will be as many rows as there are horses.

 GRayL
 'This is where you open your tables or invoke your queries to insert your data
This was going to be my next question.

You all answererd the question.
How do you eaperts want the pts devided?
FYI        I'm on 56k speed and I don't stay on line too long(If that makes any difference,slow responces):)

0
 
GRayLCommented:
Points should be awarded on a split on the basis of how well the answer helped solve your problem.  If the answers has similar or equal value, award accordingly.  If the lions share was in one answer, and one or two others added a bit, again, award accordingly.  This is one area where you have to do the math ;))

ray
0
 
nico5038Commented:
There's a >Split points link at the bottom of this question allowing you to split the points.

Nic;o)
0
 
Arthur_WoodCommented:
as pointed out, you will need to add code, after the 1435 fields have been read for a record, to assign the values to the repsective tables, as any one table cannot have more than 255 fields.  This is where you biggest problem will be.

AW
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now