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

Monday, July 11, 2011

VB-34 : Count Blanks,Tabs,etc in a String

Write a VB application to count the number of Blanks,Tabs,and Newline characters in a given string.Use appropriate controls and provide a user friendly interface.


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


Refer Total words,Characters,sentence,length of ... also

A)    Program Design : 

(B) Property(Controls Used) :
  1.       Four Labels and change their CAPTIONS as : Enter a Paragraph,White Spaces,Horizontal Tabs and New Lines.
  2.       One Command Button and change its CAPTION as Count Spaces.
  3.      Four Text Boxes and delete their Text Properties.
        (C) Attaching Code to the Object :
    
Private Sub Command1_Click()
i = 1
linecnt = 1
tabcnt = 1
spacecnt = 1
Dim str As String
str = Text1.Text

For i = 1 To Len(str)
If Mid(str, i, 1) = vbLf Then
   linecnt = linecnt + 1
ElseIf Mid(str, i, 1) = " " Then
   spacecnt = spacecnt + 1
ElseIf Mid(str, i, 1) = vbTab Then
   tabcnt = tabcnt + 1
End If
Next

Text2.Text = spacecnt
Text3.Text = tabcnt
Text4.Text = linecnt

End Sub

      • ====================================================================
        Back to Home   &  VB
    ===========================================================

    No comments: