This program will count no of words or characters present in your textbox
This program will count no of words or characters present in your textbox
API Declarations
Dim d As String * 1
Public words As Integer
Public char As Integer
Rate This program will count no of words or characters present in your textbox
(1(1 Vote))
Dim asciis As Integer
Dim asciid As Integer
Dim i As Integer
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = 1
d = RichTextBox1.SelText
words = 0
For i = 1 To Len(RichTextBox1.Text)
RichTextBox1.SelStart = i
RichTextBox1.SelLength = 1
s = RichTextBox1.SelText
asciis = Asc(s)
asciid = Asc(d)
If ((asciis = 13 Or asciis = 10) _
Or (asciis >= 32 And asciis <= 47) _
Or (asciis >= 58 And asciis <= 64) _
Or (asciis >= 91 And asciis <= 96) _
Or (AsciiThisChar >= 123 And AsciiThisChar <= 126)) _
And ((asciid >= 48 And asciid <= 57) _
Or (asciid >= 65 And asciid <= 90) _
Or (asciid >= 97 And asciid <= 122)) Then
words = words + 1
End If
d = s
Next
MsgBox "The number of words are: " & words, vbInformation
RichTextBox1.SetFocus
End Sub
Private Sub Text1_Change()
End Sub
Private Sub Command2_Click()
Dim i As Integer
Dim s As String
char = 0
For i = 1 To Len(RichTextBox1.Text) - 1
RichTextBox1.SelStart = i
RichTextBox1.SelLength = 1
If Asc(RichTextBox1.Text) > 32 And Asc(RichTextBox1.Text) <= 126 Then
char = char + 1
End If
Next
s = MsgBox("No of char are " & char, vbInformation)
RichTextBox1.SetFocus
End Sub
Private Sub Command3_Click()
RichTextBox1.Text = ""
RichTextBox1.SetFocus
End Sub
Private Sub Command4_Click()
Dim a, b As String
a = Environ("windir")
b = Left(a, 3)
dlg1.InitDir = b
dlg1.Filter = "Text files(*.txt)|*.txt"
dlg1.ShowOpen
If dlg1.FileName = "" Then
Exit Sub
End If
RichTextBox1.LoadFile dlg1.FileName
End Sub
Private Sub Command5_Click()
Dim z As String
z = MsgBox("Developed by ojas", vbInformation)
End
End Sub
This program will count no of words or characters present in your textbox Comments
No comments yet — be the first to post one!
Post a Comment