I'm a bit confused on decimal to binary number conversion. Here's my code:
Public Class Form1
Private Sub tbxDecimal_TextChanged(sender As Object, e As EventArgs) Handles tbxDecimal.TextChanged
If rdbDecmial.Checked = True And IsNumeric(tbxDecimal.Text) Then
Dim bin, dec As Double
Dim output As String
dec = Convert.ToDouble(tbxDecimal.Text)
For i = 1 To dec Step (???)
dec = i Mod 2
If i Mod 2 = 0 Then
bin = 0
Else
bin = 1
End If
output &= Convert.ToString(bin)
Next
tbxBinary.Text = output
End If
End Sub
End Class
If I typed in a decimal number in one box, the incorrect numbers come out. I know I have to have some kind of stepping size for this loop, however what should I put in?