Sunday, January 29, 2017

Square and Cube Value Solver in Visual Basic NET

Hi there in this article I would like to share with you a sample program that I wrote in Visual Basic NET to ask the user to give a number and then our program will compute the square and cube value of the given number. The code is very short and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

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

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

Public Class Form1
    Function Square(ByVal y As Integer) As Integer
        Return y ^ 2
    End Function

    Function Cube(ByVal y As Integer) As Integer
        Return y ^ 3
    End Function


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label2.Text = "The square value of " & TextBox1.Text & " is " & Square(Val(TextBox1.Text)) & "."
        Label3.Text = "The cube vallue of " & TextBox1.Text & " is " & Cube(Val(TextBox1.Text)) & "."
    End Sub

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

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




No comments:

Post a Comment