VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



CSV string parser

by Mike Baldwin (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

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".
Code 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

Download CSV string parser

Download CSV string parser (3 KB)

CSV string parser Comments

No comments have been posted about CSV string parser. Why not be the first to post a comment about CSV string parser.

Post your comment

Subject:
Message:
0/1000 characters