[tt]public function charcount(varString as variant, _
optional strReplace as string = "<") as long
if len(strString)>0 then
charcount=len(strString)-len(replace(strString, strReplace,""))
else
charcount=0
end if
end function[/tt]
If strString is "This < is < a < test" and strReplace is "<", a form control should show 3 with the following controlsource
=charcount(txtText)
If you need to count other characters, just alter the parameter to for instance
Gee - wrong declaration of the passed parameter - it's supposed to be either varString or strString all places. The code should work as a function within a form module, but perhaps put it in a standard module, so you can use it elsewhere (in VBE - insert | module)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.