Convertiseur binaire, hexa, octal et decimal

Description

Ce programme date de longtemps mais j'étais tanner de mettre des commentaires sur des sources quand je n'avais meme pas moi même poster une source alors ça va être a mon tour de me faire jugé :P

Je l'ai fait durant mon cour de binaire et hexa a l'école... c'est pour sa qu'il s'apelle Binaire2Hexa mais je l'ai évoluer avec le temps

Je ne connaissais pas la fonction Hex() et les autres s'il y en a alors j'ai tous fait a la main.

Donnez moi des commentaires svp...
Et je suis désoler si je n'ai pas mis de commentaire dans ma source car j'aime pas ben ben sa en mettre!!! Même si je sais que c'est important.

Source / Exemple :


'Exemple de code dans mon programme

Private Sub Bo_Binaire2Hexa_Click()
    Et_Hexa.Caption = ""
    Var_Len = Len(Zt_Binaire.Text)
    Var_OK = Var_Len / 4
    If Right(Var_OK, 2) = "25" Then Zt_Binaire.Text = "000" + Zt_Binaire.Text
    If Right(Var_OK, 2) = ",5" Then Zt_Binaire.Text = "00" + Zt_Binaire.Text
    If Right(Var_OK, 2) = "75" Then Zt_Binaire.Text = "0" + Zt_Binaire.Text
    Var_Len = Len(Zt_Binaire.Text)
    Do Until Var_Fois >= (Var_Len / 4)
        Var_Fois = Var_Fois + 1
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "0000" Then Et_Hexa.Caption = Et_Hexa.Caption + "0"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "0001" Then Et_Hexa.Caption = Et_Hexa.Caption + "1"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "0010" Then Et_Hexa.Caption = Et_Hexa.Caption + "2"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "0011" Then Et_Hexa.Caption = Et_Hexa.Caption + "3"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "0100" Then Et_Hexa.Caption = Et_Hexa.Caption + "4"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "0101" Then Et_Hexa.Caption = Et_Hexa.Caption + "5"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "0110" Then Et_Hexa.Caption = Et_Hexa.Caption + "6"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "0111" Then Et_Hexa.Caption = Et_Hexa.Caption + "7"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "1000" Then Et_Hexa.Caption = Et_Hexa.Caption + "8"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "1001" Then Et_Hexa.Caption = Et_Hexa.Caption + "9"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "1010" Then Et_Hexa.Caption = Et_Hexa.Caption + "A"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "1011" Then Et_Hexa.Caption = Et_Hexa.Caption + "B"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "1100" Then Et_Hexa.Caption = Et_Hexa.Caption + "C"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "1101" Then Et_Hexa.Caption = Et_Hexa.Caption + "D"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "1110" Then Et_Hexa.Caption = Et_Hexa.Caption + "E"
        If Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4) = "1111" Then Et_Hexa.Caption = Et_Hexa.Caption + "F"
    Loop
    Clipboard.SetText Et_Hexa.Caption 'Met la réponse dans le presse-papier
End Sub

'Apres modification :

Private Sub Bo_Binaire2Hexa_Click()
    Et_Hexa.Caption = ""
    Var_Len = Len(Zt_Binaire.Text)
    Var_OK = Var_Len / 4
    Select Case Right(Var_OK, 2)
        Case "25"
            Zt_Binaire.Text = "000" + Zt_Binaire.Text
        Case ",5"
            Zt_Binaire.Text = "00" + Zt_Binaire.Text
        Case "75"
            Zt_Binaire.Text = "0" + Zt_Binaire.Text
    End Select
    Var_Len = Len(Zt_Binaire.Text)
    Do Until Var_Fois >= (Var_Len / 4)
        Var_Fois = Var_Fois + 1
        Select Case Right(Left(Zt_Binaire.Text, (Var_Fois * 4)), 4)
            Case "0000"
                Et_Hexa.Caption = Et_Hexa.Caption + "0"
            Case "0001"
                Et_Hexa.Caption = Et_Hexa.Caption + "1"
            Case "0010"
                Et_Hexa.Caption = Et_Hexa.Caption + "2"
            Case "0011"
                Et_Hexa.Caption = Et_Hexa.Caption + "3"
            Case "0100"
                Et_Hexa.Caption = Et_Hexa.Caption + "4"
            Case "0101"
                Et_Hexa.Caption = Et_Hexa.Caption + "5"
            Case "0110"
                Et_Hexa.Caption = Et_Hexa.Caption + "6"
            Case "0111"
                Et_Hexa.Caption = Et_Hexa.Caption + "7"
            Case "1000"
                Et_Hexa.Caption = Et_Hexa.Caption + "8"
            Case "1001"
                Et_Hexa.Caption = Et_Hexa.Caption + "9"
            Case "1010"
                Et_Hexa.Caption = Et_Hexa.Caption + "A"
            Case "1011"
                Et_Hexa.Caption = Et_Hexa.Caption + "B"
            Case "1100"
                Et_Hexa.Caption = Et_Hexa.Caption + "C"
            Case "1101"
                Et_Hexa.Caption = Et_Hexa.Caption + "D"
            Case "1110"
                Et_Hexa.Caption = Et_Hexa.Caption + "E"
            Case "1111"
                Et_Hexa.Caption = Et_Hexa.Caption + "F"
        End Select
    Loop
    Clipboard.SetText Et_Hexa.Caption
End Sub

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.