VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Count the number of words writen in a Text box

by Vicky jadhav (VJ) (8 Submissions)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 12th June 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Count the number of words writen in a Text box

Rate Count the number of words writen in a Text box



haye Friends there are Some Intresting Program..well There is an example of it ..
you can Count the words writen in the txt box its simple watch out these one. Before this you will has to creat and form A Standard EXE Form And Put one Text Box And One Command Buton.

And Now write these codes under the command buton
-----------------------------------------------------------------------

Private Sub Command1_Click()
Dim position As Long
Dim words As Long
Dim myText As String

    position = 1
    myText = Text1.Text
    ' massage string:
    ' replace line feeds with spaces
    myText = Replace(myText, Chr(13) & Chr(10), " ")
    ' replace tabs with single spaces
    myText = Replace(myText, Chr(9), " ")
    myText = Trim(myText)
    ' Count the first word
    ' Because the last word isn't delimited by
    ' a space, if the string isn't blank, then it
    ' contains at least one word.
    ' By setting words=1, we won't have to increase the
    ' number of words by 1 when we are done counting.
    If Len(myText) > 0 Then words = 1
    ' while the string contains spaces...
    Do While position > 0
        position = InStr(position, myText, " ")
        ' ... increase word count
        If position > 0 Then
            words = words + 1
            ' and skip additional spaces
            While Mid(myText, position, 1) = " "
                position = position + 1
            Wend
        End If
    Loop
    MsgBox "The TextBox contains " & words & " words"
End Sub



Okeys Friends these is my ID [email protected] Write me soon..VJ

Download this snippet    Add to My Saved Code

Count the number of words writen in a Text box Comments

No comments have been posted about Count the number of words writen in a Text box. Why not be the first to post a comment about Count the number of words writen in a Text box.

Post your comment

Subject:
Message:
0/1000 characters