Showing posts with label Greatest Common Divisor in Visual Basic NET. Show all posts
Showing posts with label Greatest Common Divisor in Visual Basic NET. Show all posts

Wednesday, August 28, 2019

Greatest Common Divisor in Visual Basic NET

A simple program that I wrote using Visual Basic NET to ask the user two numbers and then it will compute the Greatest Common Divisor value.

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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com




Sample Program Output


Program Listing


Public Class Form1

    Public Shared Function GCD(ByVal a As Integer, ByVal b As Integer) As Integer
        If a = 0 Then
            Return b
        End If

        While b <> 0
            If a > b Then
                a -= b
            Else
                b -= a
            End If
        End While

        Return a
    End Function

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

        Dim A As Integer
        Dim B As Integer

        A = Val(TextBox1.Text)
        B = Val(TextBox2.Text)
        Dim gcd_results = GCD(A, B)

        Label3.Text = "The greatest common divisor is " & gcd_results & "."



    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Label3.Text = ""
        TextBox1.Text = ""
        TextBox1.Focus()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
End Class