Write a Vb.net program to accept number from user into the TextBox. Calculate the square root of that number also convert the entered number into binary number and display result into the Message Box

Form:-


 

Program:-

Public Class slip8

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

        Dim n, remainder, sq As Integer

        Dim sum As String

        n = CInt(TextBox1.Text)

        sq = Math.Sqrt(n)

        sum = ""

        While (n > 0)

            remainder = n Mod 2

            sum = CStr(remainder) + sum

            n = n \ 2

        End While

        MsgBox("Square root: " + CStr(sq) + " Conversion of Binary number: " + CStr(sum))

    End Sub

End Class

Output:-


Design:-

1) Take  TextBox,  Labels, Button on the design form.

2) Set Text on Button and Label.


Note - Set startup form's application type as Windows Form Application

Theory:-

Math.sqrt() - this function is used to calculate square root of numbers.

Cstr() - it is used to convert into string.

Cint() - it is used to convert into an integer type.




0 Comments