Computer Learning Zone CLZ Access Excel Word Windows

I will choose a path that's clear. I will choose free will.

-Rush
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Visual Basic Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Help With Tab Delimited File
Steven 

17 years ago
I am importing a tab delimited text file, and have a few problems.The software I'm writing in is VB6. The text file being imported, has text on the first 50 lines. The rest of the text file, has numeric values in a tab delimited format. The text on the first 50 lines, needs to be deleted, and the rest of the numeric values, needs to be written to a temporary file named "temp.dat". A sample of the first 50 lines of text data on the imported file is as follows:
~VERSION INFORMATION
VERS . 2 : CWLS Log ASCII Standard Version
WRAP . NO : One Line per Depth Step

The numeric values in the same file, starting at line 51, is as follows:
9010 4.083 34.38 6876 0 0 0 0 0 34.38 0.00 6.4 0.0 0 0.0000 0.00 0.00 0.0 0.00 04:27:55 2009/12/22
If I manually delete the first 50 lines of data, this code works. I would like to programmatically delete the first 50 lines, and then copy the rest of the values into the "temp.dat" file. The code I have follows:
[CODE]
Private Sub Command1_Click()
   Dim FileNum As Long
   Dim TotalFile As String
   Dim Records() As String
   Dim X As Long
   Dim Columns() As String
   'delete header-first 50 lines
   'this is where I am stuck
   '  Let VB generate the file channel number
   FileNum = FreeFile
   '  Reads the whole file into memory all at once
   Open "C:\DB_CUE\iball las.las" For Binary As #FileNum 'edited file
     TotalFile = Space(LOF(FileNum))
     Get #FileNum, , TotalFile
   Close #FileNum
   
   Open "c:\DB_CUE\Temp.dat" For Output As #2
   Records = Split(TotalFile, vbCrLf)
   For X = 0 To UBound(Records)
     Columns = Split(Records(X), vbTab)
   Print #2, Columns(0) & vbTab & Columns(1) & vbTab & Columns(2) & vbTab & Columns(3) _
       & vbTab & Columns(4) & vbTab & Columns(5) & vbTab & Columns(6) & vbTab & Columns(7) _
       & vbTab & Columns(8) & vbTab & Columns(9) & vbTab & Columns(10) & vbTab & Columns(11) _
       & vbTab & Columns(12) & vbTab & Columns(13) & vbTab & Columns(14) & vbTab & Columns(15) _
       & vbTab & Columns(16) & vbTab & Columns(17) & vbTab & Columns(18) & vbTab & Columns(19)
   
   Next X
   Close #2
END SUB
[/CODE]
Do you have any professional advice on how to approach this? Much help is greatly appreciated. I have researched the net and forums, and have come up with the code provided. Now I am stuck. All help is much appreciated. Thanks


Answer from Richard Rost:

Why not just open the file for reading, open a temp file for writing, loop from 1 to 50, read in a line and do nothing, then at line 51 start writing the data out to your temp file line by line. Now, once you've got this temp file made, analyze THAT file for your data. Would this work for you? If it's always 50 lines of junk, I don't see why not.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Visual Basic Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/22/2026 4:27:40 AM. PLT: 0s