[dba-VB] Count of specific character

Drew Wutka DWUTKA at Marlow.com
Wed Jul 25 08:08:21 CDT 2007


Neat trick, you could do that with Replace in VB.

Len(strTemp)-Len(Replace(strTemp,"X",""))

Drew 

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Foote, Chris
Sent: Wednesday, July 25, 2007 5:38 AM
To: 'dba-vb at databaseadvisors.com'
Subject: Re: [dba-VB] Count of specific character

Morning John!

I do not know of any specific special function to do this, but there's a
trick I use in Excel using the SUBSTITUTE function. I use LEN to get the
number of characters in the original string. Use SUBSTITUTE to replace
the character I need to count with "" (nothing). LEN the results and
subtract this from the original LEN.

Hope this helps!

Regards
Chris Foote


> -----Original Message-----
> From: dba-vb-bounces at databaseadvisors.com
> [mailto:dba-vb-bounces at databaseadvisors.com]On Behalf Of jwcolby
> Sent: Tuesday, July 24, 2007 8:33 PM
> To: dba-vb at databaseadvisors.com
> Subject: [dba-VB] Count of specific character
> 
> 
> Is there any single function that will return a count of a specific 
> character in a string?
> 
> I have a situation where (apparently) the header of a CSV file has the

> same field name twice.  I am trying to determine what is going on, so 
> I want to count the field separator characters in the header and the 
> first line of real data to see if there are more fields in the header 
> than in the data or if something else is going on.
> 
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
> 
> _______________________________________________
> dba-VB mailing list
> dba-VB at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-vb
> http://www.databaseadvisors.com
> 
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com

The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI BusinessSensitve material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.





More information about the dba-VB mailing list