Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Actual Characters 2

Status
Not open for further replies.

acct98

IS-IT--Management
Aug 15, 2002
194
US
Does anyone know the syntax or code that will count characters and not spaces?

i.e "t w" should = 2
length = 3
 
This code comes from a form I use which has the Field paragraph which contains text to be counted

and numeric field Count
code should be inserted in after update property

'==== code begins
Dim i As Integer
Me![Count] = 0
For i = 1 To 250
Me![Count] = Me![Count] + IIf(Mid$(Me![Paragraph], i, 1) = "" Or Mid$(Me![Paragraph], i, 1) = " ", 0, 1)
Next i
'======= code ends

the for next loop has been set to 250 the nos of characters in the field paragraph

Best of luck
Jimmy
 
Another option:

Code:
Dim strMyString As String
Dim lngStrLength As Long
strMyString = Replace(Me!txtMyTextbox, " ", "")
lngStrLength = Len(strMyString)

HTH...

Ken S.
 
Another option would be the following:

TheLen = Len(Replace(TheString, " ", ""))

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
**sigh** ;-)

As usual, Cajun, yours is better!

Ken S.
 
but still, the question itself is sufficiently vague to mis-lead. It ASKS for a "character count", and shows an example to avoid (aparently) counting spaces. It DOES not explain if the "character count" should also not 'count' the traditional "white space", punctuation and (or) other special characters. Nor doe the question specify even the file 'type' as plain text (could be a WORD.DOC file or an Excel.XLS or ... ?)




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Michael,
You're right. I seem to go back and forth with this kind of thing when browsing posts - should I try to look for the big picture and see if I can ferret out the question behind the question (the *root* issue)? - or just answer the question that was asked? I dunno, guess it just depends on the mood I'm in at the moment...

Ken S.
 
Eupher, I think many responses in the 'public domain' are done that way, including my own. It is just that this one seems particularly obtuse. A rose by any other name may still be a rose, but the valid alaises of 'character' (even in nerd land) are both multituninious and diverse in their meaning.



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top