Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 2nd, 2008, 12:57 PM
sal21 sal21 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 12 sal21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 18 sec
Reputation Power: 0
Read txt file line by line

Have a txt file and i want to read line by line...
Only a prob. the dimension is 49 mb !!!!
EXistis a best way to read in very fast time?
HELP!

Reply With Quote
  #2  
Old April 2nd, 2008, 03:17 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,717 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 40 m 34 sec
Reputation Power: 688
I'd be working on a way to not have a 49mb text file. That's way too big for a text file. You could store lines of text in a database table, for one.

But to read a text file you can either use the built-in file functions in vb6, or use the filesystem object.
__________________
======
Doug G
======
"Hide, hide witch! The good folk come to burn thee. Their keen enjoyment hid behind their gothic mask of duty." -Mark Clifton

Reply With Quote
  #3  
Old April 2nd, 2008, 06:19 PM
medialint's Avatar
medialint medialint is offline
spirit duplicator
Click here for more information.
 
Join Date: Apr 2004
Location: \\Firecrate\
Posts: 12,325 medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)  Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 3 Weeks 12 h 8 m 19 sec
Reputation Power: 2578
Code:
Sub ExampleReadLineByLine()
    Dim FileID As Integer
    Dim strOneLine As String
    FileID = FreeFile
    Open "e:\somefile.txt" For Input As #FileID
    Do Until EOF(FileID)
        Line Input #FileID, strOneLine
        Debug.Print strOneLine
    Loop
    Close #FileID
End Sub


It won't care if its 49GB but it will take a long time to parse ;-)
__________________
medialint.com

"Energy has the opportunity to change the climate if it's done right." - Sen. John Ensign, R-Nev. (quoted out of context)

Reply With Quote
  #4  
Old April 3rd, 2008, 01:14 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 800 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 22 h 6 m 32 sec
Reputation Power: 647
Send a message via Yahoo to zynder
49 MB? Haven't you consider making a database out of it. Why do want to read it line by line? Are you searching a keyword on the plain text file?

Reply With Quote
  #5  
Old April 3rd, 2008, 01:43 AM
sal21 sal21 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 12 sal21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 18 sec
Reputation Power: 0
Quote:
Originally Posted by zynder
49 MB? Haven't you consider making a database out of it. Why do want to read it line by line? Are you searching a keyword on the plain text file?


Yes... line by line because i want store in var a particular string from line of txt file.

Reply With Quote
  #6  
Old April 3rd, 2008, 04:08 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 800 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 22 h 6 m 32 sec
Reputation Power: 647
Send a message via Yahoo to zynder
Quote:
Originally Posted by sal21
Yes... line by line because i want store in var a particular string from line of txt file.


If you are finding for a line of text you can use Richtextbox control.

Just like Micorosoft word it has a .Find properties for finding a word in a paragraph.

Reply With Quote
  #7  
Old April 3rd, 2008, 01:19 PM
medialint's Avatar
medialint medialint is offline
spirit duplicator
Click here for more information.
 
Join Date: Apr 2004
Location: \\Firecrate\
Posts: 12,325 medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)  Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 3 Weeks 12 h 8 m 19 sec
Reputation Power: 2578
I'd try the straight read method before trying to load a 49MB file into a rich text control. I do similar to clean data in large flat files which are often 50-100MB before importing to a db (and writing to a second file to boot). Its not so painfully slow as you might think. I'd reckon on a typical computer it would run several times by the time a 49MB doc loaded into the rtf control :-)

Reply With Quote
  #8  
Old April 3rd, 2008, 05:29 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,171 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 37 sec
Reputation Power: 110
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
Seriously - I'd be using SQL Server and DTS to get that sucker into more searchable format. DTS would make short work of 49MB, a simple import wouldn't take very long to create, and it would be a hell of a lot easier to search in SQL.
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #9  
Old April 5th, 2008, 02:00 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 800 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1Folding Points: 141777 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 22 h 6 m 32 sec
Reputation Power: 647
Send a message via Yahoo to zynder
The problem is if the OP has SQL Server 2k or 2005.

Hey Medialint, I haven't tried working with 49 MB flat file because
i think it would be slow and working around with that file will put much load on the memory.

Anyway, I just cant stand the idea of having that file in the first place. Creating a database i think is the best approach.

Reply With Quote
  #10  
Old April 8th, 2008, 01:18 AM
Masino Sinaga Masino Sinaga is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Jakarta, Indonesia
Posts: 1 Masino Sinaga User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 23 sec
Reputation Power: 0
Use Microsoft Scripting Runtime (scrrun.dll) References

Hello everyone,

You may use this code. Please add first: "Microsoft Scripting Runtime (scrrun.dll)" from menu: "Project" -> "References..."

Code:
Private Sub GetRecordFromTextFile(strFileName As String) 
  On Error GoTo ErrHandler
  Dim fso As FileSystemObject
  Dim TextStream As TextStream
  Dim lRows As Long, sLine As String
  'Create object by using FSO
  Set fso = CreateObject("Scripting.FileSystemObject")
  'Open file, put the content to TextStream
  Set TextStream = fso.OpenTextFile(strFileName)
  'Loop starts here...
  Do While TextStream.AtEndOfStream = False
    'Read each line... here you can get the string each line
    'its up to you, whether you want to process this string
    'from sLine variable ... :-)
    sLine = TextStream.ReadLine
    'Update the counter
    lRows = lRows + 1 
  Loop
  'Dont forget to close the TextStream after finish
  TextStream.Close
  'If you want to get the rows from text file, get it from lRows
   Exit Sub
ErrHandler:
  MsgBox Err.Number & " - " & _
         Err.Description, _
         vbCritical, _
         "Error GetRecordFromTextFile"
End Sub


Hope this helpful. Cheers!

Best regards,
Masino Sinaga

Reply With Quote
  #11  
Old May 6th, 2008, 10:45 AM
jbcb jbcb is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 1 jbcb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 40 sec
Reputation Power: 0
javascript google map help

Hi,

I have a javascript code and HTML code. Basically I want to be able to put a number of postcode inside the Google Map.

I don't understand programming, however i think this should be a relative job for a pro. If you can help me by editing the code, it will be great.

I want to display a postcode marker on the map. To do this, the javascript will have to read it from a txt file, where all the postcode will be seperated by comma, or postcode displayed line by line, which ever ways you find it easier to write.

If possible, can you please write a loop for me, so that by just pressing one button, the script will read the code line by line? then generate the marker automatically?

I cannot post the code here, as I am a new member, if you can pm me, then i will try email u the code or something....

Thank you.

JBCB

Reply With Quote
  #12  
Old May 6th, 2008, 12:33 PM
medialint's Avatar
medialint medialint is offline
spirit duplicator
Click here for more information.
 
Join Date: Apr 2004
Location: \\Firecrate\
Posts: 12,325 medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)medialint User rank is General 24th Grade (Above 100000 Reputation Level)  Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1Folding Points: 232775 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 3 Weeks 12 h 8 m 19 sec
Reputation Power: 2578
Quote:
I have a javascript code and HTML code. Basically ... the javascript will have to read it from a txt file, where all the postcode will be seperated by comma, or postcode displayed line by line, which ever ways you find it easier to write.