If you have VB6.0 you have the Ever Handy Replace Function which you can use, eg.
Otherwise you can use the SendMessage API with the EM_GETLINECOUNT Message to Calculate the Number of Characters excluding CRLFs, eg.Code:Private Sub Command1_Click() MsgBox "Total Chars: " & Len(RichTextBox1.Text) & vbCrLf & _ "Chars, No CRLFs: " & Len(Replace(RichTextBox1.Text, vbCrLf, "")) & vbCrLf & _ "Chars, NO CRLFs, No Spaces: " & Len(Replace(Replace(RichTextBox1.Text, vbCrLf, ""), " ", "")) End Sub
Code:Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const EM_GETLINECOUNT = &HBA Private Sub Command1_Click() MsgBox "Chars, Excluding CRLF: " & Len(RichTextBox1.Text) - (2 * (SendMessage(RichTextBox1.hwnd, EM_GETLINECOUNT, 0, 0) - 1)) End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]




Reply With Quote