Wednesday, November 4, 2020

Prime Number Checker Using ASP.NET

 In this tutorial, I show you how to write a program using VB.NET and ASP.NET to ask the user to give a number and then the program will check if the given number is a prime number or not.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.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 Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price.

My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.




Program Listing

Default.aspx.vb

Public Class _Default

    Inherits System.Web.UI.Page


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        Dim a As Integer


        a = Val(txtNumber.Text)

        Dim N, D As Single

        Dim tag As String


        N = Val(TxtNumber.Text)


        Select Case N

            Case Is < 2

                Label1.Text = "The given number " & N & " is not a prime number."


            Case Is = 2

                Label1.Text = "The given number " & N & " is a prime number."


            Case Is > 2

                D = 2

                Do

                    If N / D = Int(N / D) Then

                        Label1.Text = "The given number " & N & " is not a prime number."

                        tag = "Not Prime"

                        Exit Do

                    End If

                    D = D + 1


                Loop While D <= N - 1

                If tag <> "Not Prime" Then

                    Label1.Text = "The given number " & N & " is a prime number."

                End If

        End Select



    End Sub


    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click

        txtNumber.Text = ""

        Label1.Text = ""

        txtNumber.Focus()

    End Sub

End Class


Default.aspx


<%@ Page Title="Addition of Two Numbers Using ASP.NET" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"

    CodeBehind="Default.aspx.vb" Inherits="demo._Default" %>


<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">

    <style type="text/css">

        .style1

        {

            font-size: medium;

        }

        .style2

        {

            font-family: Arial, Helvetica, sans-serif;

            font-size: medium;

        }

        </style>

</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <h2 class="style2">

        C<strong>reated By Mr. Jake R. Pomperada, MAED-IT, MIT</strong></h2>

    <p class="style1">

        <strong>Enter first value&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

        <asp:TextBox ID="txtNumber" runat="server" 

            style="font-size: medium; font-family: Arial, Helvetica, sans-serif"></asp:TextBox>

        </strong>

    </p>

    <p class="style1">

        <strong>&nbsp;<asp:Label ID="Label1" runat="server"></asp:Label>

        &nbsp;&nbsp;

        </strong>

    </p>

    <p class="style1">

        <strong>&nbsp;&nbsp; &nbsp;&nbsp;

        </strong>

        <asp:Button ID="Button1" runat="server" Font-Bold="True" Height="29px" 

            style="font-size: medium; text-align: center" Text="Check" Width="63px" 

            

            ToolTip="Click here to check if the given number is prime number or not." />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

        <asp:Button ID="Button2" runat="server" Font-Bold="True" Height="29px" 

            style="font-size: medium; text-align: center" Text="Clear" Width="63px" 

            ToolTip="Click here to clear the text box." />

    </p>

    <p class="style1">

        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</p>

    <p>

        &nbsp;</p>

</asp:Content>



No comments:

Post a Comment