[dba-VB] Count of specific character

Eric Barro ebarro at verizon.net
Wed Jul 25 09:07:29 CDT 2007


And in .NET (both VB and C#)...

strTemp.Length - strTemp.Replace("X", "").Length

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Drew Wutka
Sent: Wednesday, July 25, 2007 6:08 AM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Count of specific character

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.


_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.19/917 - Release Date: 7/25/2007
1:16 AM
 




More information about the dba-VB mailing list