import textfile to excel

Reply

Join Date: Feb 2007
Posts: 1
Reputation: Jimi.Owoseni is an unknown quantity at this point 
Solved Threads: 0
Jimi.Owoseni Jimi.Owoseni is offline Offline
Newbie Poster

import textfile to excel

 
0
  #1
Mar 3rd, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC