Binary Conversion VB.Net Program
Public Class Form1
Dim a As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer
a = CInt(TextBox1.Text)
If a <= 100 AndAlso a >= 0 Then
TextBox2.Text = Binary()
End If
End Sub
Function Binary() As String
Dim cbin As Integer
Dim result As String = ""
Dim remainder As Integer
cbin = Convert.ToInt32(TextBox1.Text)
a = 0
If cbin <> 0 Then
While cbin <> 0
remainder = cbin Mod 2
If remainder = 1 Then
a += 1
End If
result = CStr(remainder) & result
cbin = cbin \ 2
End While
Else
result = cbin
End If
Return result
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox3.Text = a
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
End Class
Comments
Post a Comment