Visitas por el Mundo:

Conversor de sistemas numéricos

Bueno gente, este es un simple sistema que permite el paso de cualquiera de los cuatro sistemas (binario, octal, decimal y hexadecimal) a cualquiera de los mismos.

El código es simple y no presenta problemas...

Una pantalla del Programa:




Haz click aquí para descargar el archivo.


Bueno eso fue todo, este es el conversor de sistemas, para VB 6.0, nos vemos, chau...
Codigo:
Dim b As Integer
Const NumChars = "0123456789ABCDEF"

Rem Transforma un número en decimal
Rem S = Número (cualquier base)
Rem NumBase = Número de la Base
Rem 2=Binario, 8=Octal, 10=Decimal, 16=Hexadecimal
Rem Si hay un error, retorna -1.
Function ToDec(ByVal S As String, ByVal NumBase As Integer) As Long
Dim R As Long, I As Integer, P As Integer
R = -1
S = UCase(S)
If (NumBase = 2) Or (NumBase = 8) Or (NumBase = 10) Or (NumBase = 16) Then
R = 0
For I = 1 To Len(S)
P = InStr(NumChars, Mid(S, I, 1))
If (P = 0) Or (P > NumBase) Then
R = -1
Exit For
End If
R = R + (P - 1) * (NumBase ^ (Len(S) - I))
Next I
End If
ToDec = R
End Function


Rem Transforma un número decimal en otras bases
Rem N = Número a convertir
Rem NumBase = Número de la Base
Rem 2=Binario, 8=Octal, 10=Decimal, 16=Hexadecimal
Rem Si hay un error, retorna una cadena vacía.
Function FromDec(ByVal N As Long, ByVal NumBase As Integer) As String
Dim S As String
S = ""
If ((NumBase = 2) Or (NumBase = 8) Or (NumBase = 10) Or (NumBase = 16)) And (N >= 0) Then
Do
S = Mid(NumChars, (N Mod NumBase) + 1, 1) + S
N = Fix(N / NumBase)
Loop Until (N = 0)
End If
FromDec = S
End Function


Rem Convierte de Cualquier base a cualquier base.
Rem N = Núero a convertir
Rem fromBase = Base de origen (2, 8, 10, 16)
Rem toBase = base destino (2, 8, 10, 16)
Function Convert(ByVal N As String, ByVal fromBase As Integer, ToBase As Integer) As String
Dim Nm As Long, S As String
Nm = ToDec(N, fromBase)
If (Nm = -1) Then
S = ""
Else
S = FromDec(Nm, ToBase)
End If
Convert = S
End Function

Private Sub Command1_Click()
Text2.Text = Convert(Val(Text1.Text), Combo1.ItemData(Combo1.ListIndex), Combo2.ItemData(Combo2.ListIndex))
End Sub

Private Sub Form_Load()
b = 1

Combo1.Clear
Combo1.AddItem "Binario"
Combo1.ItemData(Combo1.ListCount - 1) = 2
Combo1.AddItem "Octal"
Combo1.ItemData(Combo1.ListCount - 1) = 8
Combo1.AddItem "Decimal"
Combo1.ItemData(Combo1.ListCount - 1) = 10
Combo1.AddItem "Hexadecimal"
Combo1.ItemData(Combo1.ListCount - 1) = 16

Combo2.Clear
Combo2.AddItem "Binario"
Combo2.ItemData(Combo2.ListCount - 1) = 2
Combo2.AddItem "Octal"
Combo2.ItemData(Combo2.ListCount - 1) = 8
Combo2.AddItem "Decimal"
Combo2.ItemData(Combo2.ListCount - 1) = 10
Combo2.AddItem "Hexadecimal"
Combo2.ItemData(Combo2.ListCount - 1) = 16

End Sub

Private Sub Timer1_Timer()
For I = 1 To 288 Step 10
Label3.Left = Label3.Left + b
If Label3.Left >= (Form1.Width - 2190) Or Label3.Left <= 120 Then b = b * -1 End If Next I End Sub


Ante cualquier inconveniente comenten explicando su duda o problema. Si se les ocurre sugerir alguna idea para mejorar este código fuente, bienvenida sea, solo haz el comentario.

Espero que les haya gustado y hayan aprendido algo nuevo en este código fuente. Saludos, LOOk_As.

8 comentario(s):

Anónimo dijo...

oe el enlace esta dañado alojalo en megaupload puez lo necesito kon urgencia ....!!!

Anónimo dijo...

ya no esta el link habilitado

Anónimo dijo...

ok probare el codigo ya que no podia realizar el hexadecimal

Marden matos Huarmiyuri dijo...

noooooooooooooo esta weno tu aporte varon pero el link esta desavilitado :(

Marden matos Huarmiyuri dijo...

d toos modos me sirvio mucho graciass!!!

Anónimo dijo...

oie lo podras subir el archivo por favor esque lo necesito ya que en 4shared esta dañado o en mediafire

Anónimo dijo...

ESTA DAÑADO EL ARCHIVO. PORFABOR VUELVE A SUBIRLO EN OTRO DESCARGADOR-------------.

Anónimo dijo...

el link esta roto!!!!!

Publicar un comentario