Programación VB Convierta números decimales a binario y hexadecimal usando do mientras programa
Programación VB, use el bucle do- while para convertir decimal a binario y hexadecimal:
1. Convertir decimal a binario: Sub?DecimalToBinary()
Dim. ?intNumber?As?Integer
Dim?intRemainder?As?Integer
Dim?strRemainder?As?String
Dim?strBinaryNumber?As?String p>
intNumber?=?CInt(InputBox("Introducir?número?en?decimal:",?"DECIMAL?TO?BINARY?CONVERSION"))
Hacer?Mientras?intNumber ?> =?1
intRemainder?=?intNumber?Mod?2
strRemainder?=?CStr(intRemainder)
intNumber?=?intNumber?\ ?2
strBinaryNumber?=?strRemainder?&?strBinaryNumber
Bucle
MsgBox?"El?Número?en?Binario?es?:?"&? strBinaryNumber,?,?"DECIMAL?TO?BINARY?CONVERSION"
Fin?Sub
2. Convertir decimal a hexadecimal: Sub?DecimalToHexadecimal()
Dim?intNumber?As?Integer
Dim?intRemainder?As?Integer
Dim?strRemainder?As?String
Dim?strHexaNumber As?String
intNumber?=?CInt(InputBox("Introducir?número?en?decimal:",?"DECIMAL?TO?HEXADECIMAL?CONVERSION"))
¿Mientras?intNumber? >=?1
intRemainder?=?intNumber?Mod?16
strRemainder?=?CStr(intRemainder)
intNumber?=? 16
Seleccionar?Case?strRemainder
Caso?"10":?strRemainder?=?"A"
Caso?"11" :?strRemainder? =?"B"
Caso?"12":?strRemainder?=?"C"
Caso?"13":?strRemainder?=?"D "
Caso?"14":?strRemainder?=?"E"
Caso?"15":?strRemainder?=?"F"
Fin?Select
strHexaNumber?=?strRemainder?&?strHexaNumber
Bucle
MsgBox?"El?Número?en?Hexadecimal?es?:?" ,?,?"DECIMAL?A?HEXA
¿DECIMAL?CONVERSIÓN"
Fin?Sub