PROGRAMA NUMERO A BINARIO
Necesito un programa que genere el exe. y codigo fuente para hacer que numeros enteros se conviertan en binario
Este es una de las muchas maneras de hacerlo, espero te sirva de algo. Saludos.
Dim binario As String
Private Sub Command1_Click()
Dim numero, cociente, residuo As Integer
numero = Val(Text1.Text)
binario = ""
Text2.Text = ""
If numero = 0 Then
Text2.Text = 0
Exit Sub
End If
Do While numero <> 0
cociente = numero \ 2
residuo = numero Mod 2
agregar_binario (residuo)
numero = cociente
Loop
Text2.Text = StrReverse(binario)
End Sub
Public Function agregar_binario(residuo As Integer)
If residuo = 0 Then
binario = binario + "0"
Else
binario = binario + "1"
End If
End Function
Dim binario As String
Private Sub Command1_Click()
Dim numero, cociente, residuo As Integer
numero = Val(Text1.Text)
binario = ""
Text2.Text = ""
If numero = 0 Then
Text2.Text = 0
Exit Sub
End If
Do While numero <> 0
cociente = numero \ 2
residuo = numero Mod 2
agregar_binario (residuo)
numero = cociente
Loop
Text2.Text = StrReverse(binario)
End Sub
Public Function agregar_binario(residuo As Integer)
If residuo = 0 Then
binario = binario + "0"
Else
binario = binario + "1"
End If
End Function
