T
tushar
hi
the property App.Characters.Count seems to give the no of
chars + special chars like carraige return - i know how to
parse the document and remove those chars from the count -
but i was wondering if there was an easier way to
determine the no of chars with spaces - same as the menu
Tools/Word count returns.
The fn i use now is ( is there a better implmentation for
it?):
' counts chars and words in txt
' char are spaces but not special chars like carraige
return (chr13)
' params:1. txt As String - the text to count chars in
'Output: int of char count
Function cntChar(txt As String) As Integer
Dim i1 As Integer, i As Integer, d
wordCnt = 0
i1 = 0
' could have white space after white space so flag
'white space = char 13 or space
Dim inWord As Boolean
For i = 1 To Len(txt)
If (i Mod 250) = 0 Then Sheets(4).Range("b14").Value =
Sheets(4).Range("b14").Value & "."
d = Mid(txt, i, 1)
If (Asc(d) > 30) Then
i1 = i1 + 1
End If
If (Asc(d) = 32 Or Asc(d) = 13 Or Asc(d) = 10) And
inWord Then
wordCnt = wordCnt + 1
inWord = False
ElseIf (Asc(d) > 32) And Not inWord Then
inWord = True
End If
If deBg Then d = Asc(d)
Next
cntChar = i1
'Return
End Function
the property App.Characters.Count seems to give the no of
chars + special chars like carraige return - i know how to
parse the document and remove those chars from the count -
but i was wondering if there was an easier way to
determine the no of chars with spaces - same as the menu
Tools/Word count returns.
The fn i use now is ( is there a better implmentation for
it?):
' counts chars and words in txt
' char are spaces but not special chars like carraige
return (chr13)
' params:1. txt As String - the text to count chars in
'Output: int of char count
Function cntChar(txt As String) As Integer
Dim i1 As Integer, i As Integer, d
wordCnt = 0
i1 = 0
' could have white space after white space so flag
'white space = char 13 or space
Dim inWord As Boolean
For i = 1 To Len(txt)
If (i Mod 250) = 0 Then Sheets(4).Range("b14").Value =
Sheets(4).Range("b14").Value & "."
d = Mid(txt, i, 1)
If (Asc(d) > 30) Then
i1 = i1 + 1
End If
If (Asc(d) = 32 Or Asc(d) = 13 Or Asc(d) = 10) And
inWord Then
wordCnt = wordCnt + 1
inWord = False
ElseIf (Asc(d) > 32) And Not inWord Then
inWord = True
End If
If deBg Then d = Asc(d)
Next
cntChar = i1
'Return
End Function