csv - Retrieve line from text file with VBA -


i'm working on vba application want open csv file, contents of line, , store in string. i've got working, seems to bit of brute force approach , feel there should more elegant way of doing loading every single line until 1 want string.

dim rowcount long dim currentline long dim objfso, objfile const forreading = 1 rowcount = 0  set objfso = createobject("scripting.filesystemobject")         set objfile = objfso.opentextfile(filename, forreading) 'open specified file      currentline = 0                         'start line "0"     message = objfile.readline              'read contents of first line     while currentline < eventnumber      'if current line being examined not specified line         currentline = currentline + 1       'increment current line counter         message = objfile.readline          'and copy specified line message string     loop                                    'and repeat     objfile.close                           'close file when done 

can suggest better way?

also - run trouble if entry go load long? how long have be? in plc programming world standard string 82 characters, apply vba?

does csv file have header line? can use createobject("adodb.connection") execute sql query where eventnumber = something.

check out: querying csv vbs


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -