Accueil > > > CONVERTISSEUR DE CODES COULEUR DÉCIMAL - HEXADÉCIMAL - RGB
CONVERTISSEUR DE CODES COULEUR DÉCIMAL - HEXADÉCIMAL - RGB
Information sur la source
Description
Ce programme est un convertisseur pour les codes de couleurs. Il sert pour différents logiciels et différents types de programmation. Par exemple, la programmation HTML demande les codes couleurs Hexadécimaux alors que le dessin Bitmap demande les codes couleurs RGB. Les couleurs sont identiques mais il existe 3 bases (au moins) pour les appeler: - le code décimal : 1 --------> 16777216 - le code hexadécimal : 000000 --------> FFFFFF - le code RGB : 000 000 000 --------> 255 255 255 ATTENTION !!! Les codes hexadécimaux et RGB peuvent être inversés suivant les logiciels: - code hexadécimal : 0C589A --------> 9A580C (l'inversion se fait par 2 caractères) - code RGB : 253 125 034 --------> 034 125 253 Cela vient du fait que des logiciels utilisent RGB et d'autres BGR (idem pour code hexadécimal). Je vous conseille de télécharger le ZIP car trop de contrôles sont programmés à partir de la fenêtre de propriétés.
Source
- Dim TxtF As Integer
- Dim Temp As Integer
-
- Private Sub Form_Load()
- TxtF = 1
- Conversion (3)
- End Sub
-
- Private Sub AscenseurDéc_Change()
- Call AscenseurDéc_Scroll
- End Sub
-
- Private Sub AscenseurDéc_Scroll()
- Dim AD As Long
- AD = AscenseurDéc.Value
- AD = (1000 * AD) + -999
- Text1.Text = Trim(Str(AD))
- Conversion (1)
- End Sub
-
- Private Sub BoutonOK_Click()
- Conversion (TxtF) 'TxtF est le choix du Focus : La TextBox qui a le focus garde sa valeur et les autres TextBox changent de valeur en fonction de celle-ci
- End Sub
-
- Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
- Temp = Text1.SelStart
- If KeyCode = vbKeyBack And Text1.SelStart <> 0 Then
- Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
- Text1.SelStart = Temp - 1
- End If
- End Sub
-
- Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
- Temp = Text2.SelStart
- If KeyCode = vbKeyBack And Text2.SelStart <> 0 Then
- Text2.Text = Left(Text2.Text, Len(Text2.Text) - 1)
- Text2.SelStart = Temp - 1
- End If
- End Sub
-
- Private Sub Text3_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
- Temp = Text3(Index).SelStart
- If KeyCode = vbKeyBack And Text3(Index).SelStart <> 0 Then
- Text3(Index).Text = Left(Text3(Index).Text, Len(Text3(Index).Text) - 1)
- Text3(Index).SelStart = Temp - 1
- End If
- End Sub
-
- Private Sub Text1_KeyPress(KeyAscii As Integer)
- If InStr("0123456789" & vbKeyBack & vbKeyDelete, Chr(KeyAscii)) = 0 Then KeyAscii = 0 'Filtrage de la saisie
- End Sub
-
- Private Sub Text2_KeyPress(KeyAscii As Integer)
- If InStr("0123456789abcdefABCDEF" & vbKeyDelete, Chr(KeyAscii)) = 0 Then KeyAscii = 0 'Filtrage de la saisie
- If InStr("abcdef", Chr(KeyAscii)) Then KeyAscii = KeyAscii - 32
- End Sub
-
- Private Sub Text3_KeyPress(Index As Integer, KeyAscii As Integer)
- If InStr("0123456789" & vbKeyDelete, Chr(KeyAscii)) = 0 Then KeyAscii = 0 'Filtrage de la saisie
- End Sub
-
- Private Sub Text1_Validate(Cancel As Boolean)
- If Text1.Text = "" Then Text1.Text = "00000001"
- Formatage
- End Sub
-
- Private Sub Text2_Validate(Cancel As Boolean)
- If Text2.Text = "" Then Text2.Text = "000000"
- Formatage
- End Sub
-
- Private Sub Text3_Validate(Index As Integer, Cancel As Boolean)
- If Text3(Index).Text = "" Then Text3(Index).Text = "000"
- Formatage
- End Sub
-
- Private Sub Text1_GotFocus()
- TxtF = 1
- End Sub
-
- Private Sub Text2_GotFocus()
- TxtF = 2
- End Sub
-
- Private Sub Text3_GotFocus(Index As Integer)
- TxtF = 3
- End Sub
-
- Private Sub UpDown1_Change(Index As Integer)
- Text3(Index).Text = Format(Text3(Index).Text, "000")
- Conversion (3)
- End Sub
-
- Private Sub UpDown2_Change(Index As Integer)
- Text4(Index).Text = Format(Text4(Index).Text, "000")
- Conversion (4)
- End Sub
-
- Sub Conversion(TxtFormat)
- On Error Resume Next 'Facultatif sauf si le code comporte des bugs (??)
- Formatage
- Select Case TxtFormat
- Case 1
- Text3(2).Text = Trim(Str(Int(Val(Text1.Text) / 65536)))
- Text3(1).Text = Trim(Str(Int((Val(Text1.Text) - 65536 * Val(Text3(2).Text)) / 256)))
- Text3(0).Text = Trim(Str(Int(Val(Text1.Text) - 65536 * Val(Text3(2).Text) - 256 * Val(Text3(1).Text))))
- Text2.Text = Hex(Text1.Text - 1)
- Case 2
- For i% = 5 To 0 Step -1
- If Asc(Mid(Text2.Text, i% + 1, 1)) > 64 Then Text3(Int(i% / 2)).Text = Trim(Str(Val(Text3(Int(i% / 2)).Text) + (Asc(Mid(Text2.Text, i% + 1, 1)) - 55) * (16 ^ Abs(Round((i% / 2) - Int(i% / 2) + 0.1) - 1)))) Else Text3(Int(i% / 2)).Text = Trim(Str(Val(Text3(Int(i% / 2)).Text) + Val(Mid(Text2.Text, i% + 1, 1) * (16 ^ Abs(Round((i% / 2) - Int(i% / 2) + 0.1) - 1)))))
- Text1.Text = Trim(Str(Val(Text3(0).Text) + Val(Text3(1).Text) * 256 + Val(Text3(2).Text) * 65536 + 1))
- Next i%
- Case 3
- Text1.Text = Trim(Str(Val(Text3(0).Text) + Val(Text3(1).Text) * 256 + Val(Text3(2).Text) * 65536 + 1))
- Text2.Text = Hex(Text1.Text - 1)
- Case 4
- 'en attente
- End Select
- PictureAperçu(0).BackColor = "&H" + Text2.Text
- PictureAperçu(1).BackColor = "&H" & Hex((Val(Text3(0).Text) + Val(Text3(1).Text) + Val(Text3(2).Text)) / 3) & Hex((Val(Text3(0).Text) + Val(Text3(1).Text) + Val(Text3(2).Text)) / 3) & Hex((Val(Text3(0).Text) + Val(Text3(1).Text) + Val(Text3(2).Text)) / 3)
- Formatage
- End Sub
-
- Sub Formatage()
- If Val(Text1.Text) > 16777216 Then Text1.Text = "16777216" 'Eviter les dépassements de valeurs
- For Each Element In Text3()
- If Val(Element.Text) > 255 Then Element.Text = "255"
- Next Element
- Text1.Text = Format(Text1.Text, "00000000")
- If Len(Text2.Text) <> 6 Then
- For i% = 0 To 5 - Len(Text2.Text)
- Text2.Text = Text2.Text & "0"
- Next i%
- End If
- For Each Element In Text3()
- Element.Text = Format(Element.Text, "000")
- Next Element
- For Each Element In Text4()
- Element.Text = Format(Element.Text, "000")
- Next Element
- End Sub
Dim TxtF As Integer
Dim Temp As Integer
Private Sub Form_Load()
TxtF = 1
Conversion (3)
End Sub
Private Sub AscenseurDéc_Change()
Call AscenseurDéc_Scroll
End Sub
Private Sub AscenseurDéc_Scroll()
Dim AD As Long
AD = AscenseurDéc.Value
AD = (1000 * AD) + -999
Text1.Text = Trim(Str(AD))
Conversion (1)
End Sub
Private Sub BoutonOK_Click()
Conversion (TxtF) 'TxtF est le choix du Focus : La TextBox qui a le focus garde sa valeur et les autres TextBox changent de valeur en fonction de celle-ci
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Temp = Text1.SelStart
If KeyCode = vbKeyBack And Text1.SelStart <> 0 Then
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
Text1.SelStart = Temp - 1
End If
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
Temp = Text2.SelStart
If KeyCode = vbKeyBack And Text2.SelStart <> 0 Then
Text2.Text = Left(Text2.Text, Len(Text2.Text) - 1)
Text2.SelStart = Temp - 1
End If
End Sub
Private Sub Text3_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
Temp = Text3(Index).SelStart
If KeyCode = vbKeyBack And Text3(Index).SelStart <> 0 Then
Text3(Index).Text = Left(Text3(Index).Text, Len(Text3(Index).Text) - 1)
Text3(Index).SelStart = Temp - 1
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If InStr("0123456789" & vbKeyBack & vbKeyDelete, Chr(KeyAscii)) = 0 Then KeyAscii = 0 'Filtrage de la saisie
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If InStr("0123456789abcdefABCDEF" & vbKeyDelete, Chr(KeyAscii)) = 0 Then KeyAscii = 0 'Filtrage de la saisie
If InStr("abcdef", Chr(KeyAscii)) Then KeyAscii = KeyAscii - 32
End Sub
Private Sub Text3_KeyPress(Index As Integer, KeyAscii As Integer)
If InStr("0123456789" & vbKeyDelete, Chr(KeyAscii)) = 0 Then KeyAscii = 0 'Filtrage de la saisie
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
If Text1.Text = "" Then Text1.Text = "00000001"
Formatage
End Sub
Private Sub Text2_Validate(Cancel As Boolean)
If Text2.Text = "" Then Text2.Text = "000000"
Formatage
End Sub
Private Sub Text3_Validate(Index As Integer, Cancel As Boolean)
If Text3(Index).Text = "" Then Text3(Index).Text = "000"
Formatage
End Sub
Private Sub Text1_GotFocus()
TxtF = 1
End Sub
Private Sub Text2_GotFocus()
TxtF = 2
End Sub
Private Sub Text3_GotFocus(Index As Integer)
TxtF = 3
End Sub
Private Sub UpDown1_Change(Index As Integer)
Text3(Index).Text = Format(Text3(Index).Text, "000")
Conversion (3)
End Sub
Private Sub UpDown2_Change(Index As Integer)
Text4(Index).Text = Format(Text4(Index).Text, "000")
Conversion (4)
End Sub
Sub Conversion(TxtFormat)
On Error Resume Next 'Facultatif sauf si le code comporte des bugs (??)
Formatage
Select Case TxtFormat
Case 1
Text3(2).Text = Trim(Str(Int(Val(Text1.Text) / 65536)))
Text3(1).Text = Trim(Str(Int((Val(Text1.Text) - 65536 * Val(Text3(2).Text)) / 256)))
Text3(0).Text = Trim(Str(Int(Val(Text1.Text) - 65536 * Val(Text3(2).Text) - 256 * Val(Text3(1).Text))))
Text2.Text = Hex(Text1.Text - 1)
Case 2
For i% = 5 To 0 Step -1
If Asc(Mid(Text2.Text, i% + 1, 1)) > 64 Then Text3(Int(i% / 2)).Text = Trim(Str(Val(Text3(Int(i% / 2)).Text) + (Asc(Mid(Text2.Text, i% + 1, 1)) - 55) * (16 ^ Abs(Round((i% / 2) - Int(i% / 2) + 0.1) - 1)))) Else Text3(Int(i% / 2)).Text = Trim(Str(Val(Text3(Int(i% / 2)).Text) + Val(Mid(Text2.Text, i% + 1, 1) * (16 ^ Abs(Round((i% / 2) - Int(i% / 2) + 0.1) - 1)))))
Text1.Text = Trim(Str(Val(Text3(0).Text) + Val(Text3(1).Text) * 256 + Val(Text3(2).Text) * 65536 + 1))
Next i%
Case 3
Text1.Text = Trim(Str(Val(Text3(0).Text) + Val(Text3(1).Text) * 256 + Val(Text3(2).Text) * 65536 + 1))
Text2.Text = Hex(Text1.Text - 1)
Case 4
'en attente
End Select
PictureAperçu(0).BackColor = "&H" + Text2.Text
PictureAperçu(1).BackColor = "&H" & Hex((Val(Text3(0).Text) + Val(Text3(1).Text) + Val(Text3(2).Text)) / 3) & Hex((Val(Text3(0).Text) + Val(Text3(1).Text) + Val(Text3(2).Text)) / 3) & Hex((Val(Text3(0).Text) + Val(Text3(1).Text) + Val(Text3(2).Text)) / 3)
Formatage
End Sub
Sub Formatage()
If Val(Text1.Text) > 16777216 Then Text1.Text = "16777216" 'Eviter les dépassements de valeurs
For Each Element In Text3()
If Val(Element.Text) > 255 Then Element.Text = "255"
Next Element
Text1.Text = Format(Text1.Text, "00000000")
If Len(Text2.Text) <> 6 Then
For i% = 0 To 5 - Len(Text2.Text)
Text2.Text = Text2.Text & "0"
Next i%
End If
For Each Element In Text3()
Element.Text = Format(Element.Text, "000")
Next Element
For Each Element In Text4()
Element.Text = Format(Element.Text, "000")
Next Element
End Sub
Conclusion
Si ce code comportait des bugs, merci de me le signaler.
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
recuperer code hexa entier d'une couleur [ par NaBuCO ]
voila mon pb c ke je ve recuperer le code hexa de la couleur que choisi l'utilisateur ds la palette tout va bien qd c a 6 caractere genre FFFFFF (pour
transformer le code couleur en nom couleur [ par mido105 ]
slt tt le monde, je développe avec vba excel, j'ai une interface dans la quelle l'utilisateur choisie une couleur je recupére aprés le code hexa de c
Encodage couleur [ par cheyenne ]
Bonjour, Je cherche le moyen de coder une palette de 256 couleurs de la manière la plus compacte pour l'inscrire dans un fichier ini. Pour l'instant
Shape et couleur [ par Sinsitrus ]
Salut ! Depuis un combo j'aimerais donner une couleur de bord à des shape indexés de 0 à 76 Les shapes s'appellent ainsi : ZoneCadr(0) à ZoneCadr(76)
problème dégradé de couleur reconnaissance de caractères [ par dieu360 ]
bonjour! voilà mon problème, dans la reconnaissance de caractère(chiffres) j'utilise la fonction getpixel pour identifier la couleur des pixels, et do
Imprimer le code en couleur [ par NYghost ]
Hi all ! Voila je dois foutre du code VB dans un rapport et j'aimerai bien imprimer le code avec les couleurs et tabulations.. Je sais ca sert a rien
Socket envoi code Hexa [ par GLoarb ]
Bonjour,Je cherche a envoyer du code hexadecimal sur un socket, ex: 00 00 00 00 00 0e 00 00 00 0e 00 02 00 a0 00 02 </fon
Conversion d'une date en secondes [ par Makia42 ]
Bonjour, Voila, je suis toujours sur mon projet destiné à la supervision de capteurs à distances (pour ceux qui me connaisse un peu à force [^^happy8
access 2010 [ par anofer ]
bonjour, je suis debutant, mon probleme a resoudre est le suivant : j'ai deux tables code article ref designation et la deuxieme est une table de stoc
VBSCRIPT Conversion d'une date en hexa et inversement [ par Sbt ]
Salut à tous,dans la base de registre, j'ai une valeur hexadécimale (25 00 16 00 00 00 00 00)On m'a dit que c'était une date (22/01/2007) et je cherch
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|