Couleur vb en couleur Web

pcpunch Messages postés 1243 Date d'inscription mardi 7 mai 2002 Statut Membre Dernière intervention 18 février 2019 - 5 avril 2003 à 13:02
avelis Messages postés 22 Date d'inscription lundi 13 novembre 2000 Statut Membre Dernière intervention 6 août 2006 - 18 août 2005 à 11:59
Slt je cherche un moyen de transformer une couleur vb en courleur Web (format RRGGBB Hex : Code couelur pour Skin Bsplayer)

G bien une source mais ca fonctionne pas!!!
Qd je selectionne le rouge c du bleue qui en resulte???

Private Sub Command37_Click()
With CommonDialog1
.Flags = cdlCCRRGBInit
.ShowColor
colortxt.BackColor = .Color ' c un controle im qui affiche la couelur VB
txt1.ForeColor = .Color
txt2.ForeColor = .Color
txt3.ForeColor = .Color
txt4.ForeColor = .Color
txt5.ForeColor = .Color
txt6.ForeColor = .Color
'convertion de la couleur en html RRGGBB hex
Dim Strcolor As String
Dim strnum1, strnum2, strnum3 As String
Strcolor = Hex$(colortxt.BackColor)

Do Until Len(Strcolor) = 6
Strcolor = Strcolor & "0"
Loop

strnum1 = Right(Strcolor, 2)
strnum2 = Mid(Strcolor, 3, 2)
strnum3 = Left(Strcolor, 2)

txtcouleur = strnum1 & strnum2 & strnum3
End With

End Sub
comment puis je resoudre ce probleme?

1 réponse

avelis Messages postés 22 Date d'inscription lundi 13 novembre 2000 Statut Membre Dernière intervention 6 août 2006
18 août 2005 à 11:59
Je répond aussi sur cette page au cas où...

Salut, je suis tombé sur le même problème car j'utilisais Format(Hex(color),"000000") mais ca marche pas dans le cas où le nombre s'écrit avec des caractères hexa (A-F) donc j'ai fait la petite procédure suivante :

Dim strR As String
Dim strG As String
Dim strB As String
Dim strColor As String

strR = Hex(dlgFont.Color And 255)
strG = Hex(dlgFont.Color \ 256 And 255)
strB = Hex(dlgFont.Color \ 65536 And 255) If Len(strR) 1 Then strR "0" & strR If Len(strG) 1 Then strG "0" & strG If Len(strB) 1 Then strB "0" & strB
strColor = strR & strG & strB

J'espère que c'est bien ce que tu voulais :)
J'ai fait pas mal de test ca à l'air de fonctionner !
0
Rejoignez-nous