Showing posts with label vowels in ms access. Show all posts
Showing posts with label vowels in ms access. Show all posts

Friday, January 5, 2018

Vowels and Consonants Counter in Microsoft Access

In this article I would like to share with you a sample program that will ask the user to give a sentence and then our program will count the number of vowels and consonants in given sentence by our user. I am using Microsoft Access 2010 as my programming tool in writing this program.

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 Vowels and Consonants in Microsoft Access
' Written By Mr. Jake R. Pomperada, MAED-IT
' January 5, 2018  Frinday

Option Compare Database

Const vowels = "aeiou"
Const consonants = "bcdfghjklmnpqrstvwxyz"

' This function will count the number of vowels in a given sentence
Private Function CountVowels(strText As String) As Integer
    Dim i As Integer
 Dim asciiToSearchFor As Integer
    For i = 1 To Len(LCase(strText))
        If InStr(1, vowels, Mid$(strText, i, 1), vbTextCompare) Then
            CountVowels = CountVowels + 1
         End If
    Next i
End Function

' This function will count the number of consonants in a given sentence
Private Function CountConsonants(strText As String) As Integer
    Dim i As Integer
 Dim asciiToSearchFor As Integer
    For i = 1 To Len(LCase(strText))
        If InStr(1, consonants, Mid$(strText, i, 1), vbTextCompare) Then
            CountConsonants = CountConsonants + 1
         End If
    Next i
End Function
Private Sub Command16_Click()
Dim vowels_count As Integer
Dim consonants_count As Integer


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

vowels_count = CountVowels(Me.Text13)
consonants_count = CountConsonants(Me.Text13)

 Me.Label15.Caption = "Total number of consonants is " + Str(vowels_count) + "."
 Me.Label19.Caption = "Total number of vowels is " + Str(consonants_count) + "."

End Sub


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

Private Sub Command18_Click()
DoCmd.OpenForm "frmAbout"

End Sub

Private Sub Form_Click()

End Sub