Code for counting commas in a text field?

  • Thread starter Thread starter Chris Nebinger
  • Start date Start date
C

Chris Nebinger

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.
 
Your way is less code!

Kat
Chris Nebinger said:
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


number of commas in a text field? I would like the
expression to return a number plus one.
 
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
 
Back
Top