VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

CSV string parser

Mike Baldwin  (1 Submission)   String Manipulation   Visual Basic 5.0   Intermediate   Wed 3rd February 2021

This function takes a comma separated string and parses the values into a variable-length array, which can then be assigned to a predefined number of variables, or iterated with a For-Next loop. This code is roughly based on Brant Gluth's submission entitled "Parse Delimited Text", with the addition of a demo form and improved string handling. Most noticeably, this code can handle strings enclosed in quotes and will not break on delimiter characters within the quotes.

Inputs
strSource - string containing CSV text. strDelimiter - optional string value representing the delimiter, default is a comma. strQuote - optional string value representing the quotation mark character, default is ".

Assumes
All you need to implement this code in your own program is the module "readcsv.bas".

Returns
variable-length variant array containing each field from the CSV line.

Side Effects
None. Does not crash when given an empty string or improperly formatted text.

Rate CSV string parser (5(5 Vote))

Download CSV string parser

CSV string parser Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters