Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Sunday, August 7, 2011

VB-83 : Total words,Characters,sentence,length of strings

Write an event procedure and develop an application to intake 2 strings text , Concatenate them and find total number of words,total number of characters (between A to Z) , total number of sentences and total length of the resultant text.


Click to see a simple program of this type The number of digits in the entered Number...


Refer  Resultant Length of 2 concatenated Strings...and  Occurrence of a String also.



(A)Program Design : 






(B) Property(Controls Used) :
  • 7 labels for TextBoxes
  • 3 TextBoxes (Text1,2 and resultant text)
  • 4 TextBoxes (Name Text4,5,6 & & respectively , to get the results
  • 2 Command Buttons Find & Cancel (Command 1 & 2 are names)

(C) Attaching Code to the Object :





Private Sub Command2_Click()
Unload Me
End Sub


Private Sub Command1_Click()
Dim str As String
Dim wordcount, sentencecount, charcount
wordcount = 1
sentencecount = 1
charcount = 0
str = Text1.Text + Text2.Text
For i = 1 To Len(str)
   If Mid(str, i, 1) = " " Then 'include a single space inside quotes
   wordcount = wordcount + 1
   Else
        If Mid(str, i, 1) = "." Or Mid(str, i, 1) = "?" Then
        sentencecount = sentencecount + 1
        Else
            If (Asc(Mid(str, i, 1)) >= 65 And Asc(Mid(str, i, 1)) <= 90) Or (Asc(Mid(str, i, 1)) >= 97 And Asc(Mid(str, i, 1)) <= 122) Then
            charcount = charcount + 1
            End If
        End If
    End If
Next
Text3.Text = str
Text4.Text = wordcount
Text5.Text = charcount
Text6.Text = Len(str)
Text7.Text = sentencecount
End Sub




(D) Output :


(E) Errors :

If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.
      • ====================================================================
        Back to Home   &  VB
    ===========================================================

    No comments: