Showing posts with label word count in ms access. Show all posts
Showing posts with label word count in ms access. Show all posts

Friday, January 5, 2018

Word Counter in Microsoft Access

A very simple program that I wrote using Microsoft Access to ask the user to give a string or a sentence and then our program will count the number of words in the given sentence. 

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.







Sample Program Output



Program Listing

'Count Words in a Sentence in Microsoft Access
' Written By Mr. Jake R. Pomperada, MAED-IT
' January 5, 2018  Frinday

Option Compare Database

Public Function WordCounter(Text As String) As Integer
Dim Counts As Integer
Dim dupText As String
dupText = Replace(Trim(Text), vbNewLine, " ")
If dupText = "" Then
    Counts = 0
Else
    Counts = 1
    For i = 1 To Len(dupText)
        If Mid(dupText, i, 1) = " " Then ' use Mid to search space
            If Mid(dupText, i - 1, 1) <> " " Then
                Counts = Counts + 1
            End If
        End If
    Next
    
Me.Label15.Caption = "Total number of words is " + Str(Counts) + "."
End If

End Function
Private Sub Command16_Click()
Dim word_count As Integer

If Len(Trim(Me.Text13) & vbNullString) = 0 Then
     MsgBox "Enter a sentence", vbInformation
     Me.Text13.SetFocus
     Exit Sub
End If
 WordCounter (Me.Text13)

End Sub


Private Sub Command17_Click()
Me.Text13 = ""
Me.Label15.Caption = ""
Me.Text13.SetFocus
End Sub

Private Sub Command18_Click()
DoCmd.OpenForm "frmAbout"

End Sub