Public Class frm
Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
If rdb.Checked = True Then
If Val(txt.Text) > 255 Then
MessageBox.Show("OHNOES!!1 Number must be =< 255, Superman.")
Else
Dim x, y As Integer
Dim z As String
x = txt.Text
Do Until x = 0
y = x Mod 2
x = x \ 2
z = y & z
Loop
Do Until z.Length = 8
z = 0 & z
Loop
Me.Text = z
End If
ElseIf rdd.Checked = True Then
Dim x(1, 7) As Integer
Dim binstr As String
Dim y As String
Dim z = 128
binstr = txt.Text
Do Until binstr.Length = 8
binstr = 0 & binstr
Loop
For x(0, 0) = 0 To 7
x(1, x(0, 0)) = Val(binstr(x(0, 0)))
y = y + x(1, x(0, 0)) * z
z = z / 2
Next
Me.Text = y
End If
End Sub
End Class