Showing posts with label prime number in ms access. Show all posts
Showing posts with label prime number in ms access. Show all posts

Wednesday, January 17, 2018

Prime Number Checker in Microsoft Access

In this article I would like to share with you a sample program that will ask the user to give a number and then our program will check if the given number in prime number or not using Microsoft Access. I am using Microsoft Access 2010 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

Option Compare Database

Public Function PrimeNumberChecker(sinput) As Boolean
    PrimeNumberChecker = True
    If sinput = 1 Then
        PrimeNumberChecker = False
    ElseIf sinput > 2 Then
        For i = 2 To sinput - 1
            If sinput Mod i = 0 Then
                PrimeNumberChecker = False
                Exit Function
            End If
        Next i
    End If
End Function

Private Sub Command16_Click()
Dim a As Integer


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

a = Val(Me.Text13)

If PrimeNumberChecker(a) = True Then
   Me.Label15.Caption = "The given number " + Str(a) + " is a Prime Number."
Else
  Me.Label15.Caption = "The given number " + Str(a) + " is Not a Prime Number."
End If
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