943,973 Members | Top Members by Rank

Ad:
Mar 3rd, 2007
0

import textfile to excel

Expand Post »
Hi All,
I have a problem to solve.I am importing 200000 records(.txt) in notepad into excel but when it gets to 65000 records it truncates telling me that not completely exported.I now write a code in vb editor(excel) trying to count every 5records and export to excel.Please, have a look at this code and correct.Thanks.
rgds
jimi
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Public NumberOfRecords As Integer
  2. Dim data(i, 2) As String
  3. Dim g, fileName As String
  4. Dim i, numlines, lines, As Integer
  5.  
  6. Dim line_Name(i), short_Point(i), x(i), y(i), s(i) As Double
  7. Private Sub OpenFileBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFileBtn.Click
  8. If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then 'opens file of users choice if cancel not pressed
  9. FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
  10. lines = getNumLines(1)
  11. FileClose (1)
  12. FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
  13. ReDim data(lines, 2)
  14. For i = 0 To i = lines - 1
  15. Input(1, data(i, 0))
  16. Input(1, data(i, 1))
  17. Input(1, data(i, 2))
  18. line_Name(i) = Val(data(i, 0))
  19. short_Point(i) = Val(data(i, 1))
  20. x(i) = Val(data(i, 2))
  21. y(i) = Val(data(i, 3))
  22. s(i) = Val(data(i, 4))
  23.  
  24. Next i
  25. FileClose (1)
  26. End If
  27. End Sub
  28. Public Function getNumLines(ByVal fileName As Integer) As Integer
  29. Dim numlines As Integer
  30. numlines = 0
  31. While Not (EOF(1))
  32. numlines = numlines + 5 'counts number of rows in the file
  33. Input(5, g)
  34. End While
  35. Return numLines 'return the number of lines found
  36. End Function
  37. End Class
Last edited by Comatose; Mar 9th, 2007 at 4:34 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jimi.Owoseni is offline Offline
1 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: ADODB Y DAO together ?
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Is This Project Possible?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC