PC Review


Reply
Thread Tools Rate Thread

Code for counting commas in a text field?

 
 
Chris Nebinger
Guest
Posts: n/a
 
      15th Jun 2004
There are many different ways to do this. One of them is:

Public Function CountCommas(strInput As String) As Integer
Dim Values() As String
Values = Split(strInput, ",")
CountCommas = UBound(Values)
End Function


Chris Nebinger


>-----Original Message-----
>Can you help with the Access expression for counting the

number of commas in a text field? I would like the
expression to return a number plus one.
>
>The text field containing the data is named, "notes"
>
>So, if the text field contains:
>C10, C20, C30
>
>The expression should return a number 3.
>
>Many thanks,
>Matt
>.
>

 
Reply With Quote
 
 
 
 
Katrina
Guest
Posts: n/a
 
      15th Jun 2004
Your way is less code!

Kat
"Chris Nebinger" <(E-Mail Removed)> wrote in message
news:1c83f01c452f7$065c5290$(E-Mail Removed)...
> There are many different ways to do this. One of them is:
>
> Public Function CountCommas(strInput As String) As Integer
> Dim Values() As String
> Values = Split(strInput, ",")
> CountCommas = UBound(Values)
> End Function
>
>
> Chris Nebinger
>
>
> >-----Original Message-----
> >Can you help with the Access expression for counting the

> number of commas in a text field? I would like the
> expression to return a number plus one.
> >
> >The text field containing the data is named, "notes"
> >
> >So, if the text field contains:
> >C10, C20, C30
> >
> >The expression should return a number 3.
> >
> >Many thanks,
> >Matt
> >.
> >



 
Reply With Quote
 
Chris Nebinger
Guest
Posts: n/a
 
      15th Jun 2004
There is almost always more than one way to do anything.
As long as it works, that's what matters.
If this was a function being called alot, maybe as a query
field, then I would look hard at which way was more
effecient. I'm not sure which would be, but I have an
idea using the Split function would be a bit quicker.

Chris Nebinger


>-----Original Message-----
>Your way is less code!
>
>Kat
>"Chris Nebinger" <(E-Mail Removed)>

wrote in message
>news:1c83f01c452f7$065c5290$(E-Mail Removed)...
>> There are many different ways to do this. One of them

is:
>>
>> Public Function CountCommas(strInput As String) As

Integer
>> Dim Values() As String
>> Values = Split(strInput, ",")
>> CountCommas = UBound(Values)
>> End Function
>>
>>
>> Chris Nebinger
>>
>>
>> >-----Original Message-----
>> >Can you help with the Access expression for counting

the
>> number of commas in a text field? I would like the
>> expression to return a number plus one.
>> >
>> >The text field containing the data is named, "notes"
>> >
>> >So, if the text field contains:
>> >C10, C20, C30
>> >
>> >The expression should return a number 3.
>> >
>> >Many thanks,
>> >Matt
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel VBA - Force 4 commas into a text field on userform kazzy Microsoft Excel Discussion 7 3rd Feb 2011 08:42 AM
counting the number of commas within a text string Ron.Winkley@gmail.com Microsoft Excel Discussion 2 10th Jul 2008 08:13 PM
Parse text field based on spaces or commas or periods =?Utf-8?B?SmVubmlmZXI=?= Microsoft Excel Misc 1 22nd Oct 2004 09:35 PM
parsing text field based on commas or spaces =?Utf-8?B?RXhjZWwgVXNlcg==?= Microsoft Excel Programming 1 22nd Oct 2004 09:34 PM
Re: Code for counting commas in a text field? Katrina Microsoft Access VBA Modules 2 16th Jun 2004 10:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:54 PM.