[dba-VB] Count a character in a string

jwcolby jwcolby at colbyconsulting.com
Sat Apr 12 15:23:49 CDT 2008


I do a lot of CSV stuff.  One of my file suppliers gives me files that 
throw an error when I try to import them and so I am writing tools to 
try and troubleshoot these files.  I need to be able to count the times 
that the field separator character is contained in a line.  The error I 
am getting says the line is too long but I have determined that is not 
the case.  I suspect that perhaps the field separator character is in 
the line too often.

So, if I have a line that looks like:

asdf|qwert|zxcv|mnbv

Other than just iterating through the string character by character, is 
there a way to get a count of the | character in the string?
-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-VB mailing list