Tipp 0122 Farbwerte berechnen
Autor/Einsender:
Datum:
  Ronald Janowski
27.08.2001
Entwicklungsumgebung:   VB 6
Dieser Tipp zeigt wie man den Hex-Wert der VB-Farben in den richtigen Farb-Wert für Webseiten konvertiert. Zusätzlich wird der Farbwert noch als RGB-Wert angezeigt.
 
Option Explicit

Public Function convColor(tBCDummy As String) As String
  Dim tBCDummy1 As String
  Dim cF As Integer

  If Len(tBCDummy) < 6 Then
    tBCDummy1 = tBCDummy
    tBCDummy = ""
    For cF = (Len(tBCDummy1) + 1) To 6
      tBCDummy = tBCDummy & "0"
    Next cF
    tBCDummy = tBCDummy & tBCDummy1
  End If

  convColor = ""
  convColor = convColor & Mid$(tBCDummy, 5, 2)
  convColor = convColor & Mid$(tBCDummy, 3, 2)
  convColor = convColor & Mid$(tBCDummy, 1, 2)
End Function

Public Function rgbColor(conColor As String) As String
  Dim r As String
  Dim g As String
  Dim b As String

  rgbColor = ""
  r = "&H" & Mid(conColor, 1, 2)
  g = "&H" & Mid(conColor, 3, 2)
  b = "&H" & Mid(conColor, 5, 2)
  rgbColor = "RGB(" & CDec(r) & ", " & CDec(g) & ", " & _
        CDec(b) & ")"
End Function
 
Code im Codebereich der Form
 
Option Explicit

Dim cColor As String

Private Sub lblChooseColor_Click()
  CD1.CancelError = False
  CD1.Flags = &H2
  CD1.ShowColor

  lblChooseColor.BackColor = CD1.Color
  txtFarbWert(0).Text = "&H" & Hex(CD1.Color)

  cColor = convColor(Hex(lblChooseColor.BackColor))
  txtFarbWert(1).Text = "#" & cColor

  txtFarbWert(2).Text = rgbColor(cColor)
End Sub
 
Weitere Links zum Thema
Color Picker
Color Picker - 2 -
RGB Farbanteile

Windows-Version
95
98/SE
ME
NT
2000
XP
Vista
Win 7
VB-Version
VBA 5
VBA 6
VB 4/16
VB 4/32
VB 5
VB 6


Download  (3,2 kB) Downloads bisher: [ 1262 ]

Vorheriger Tipp Zum Seitenanfang Nächster Tipp

Startseite | Projekte | Tutorials | API-Referenz | VB-/VBA-Tipps | Komponenten | Bücherecke | VB/VBA-Forum | VB.Net-Forum | DirectX-Forum | Foren-Archiv | DirectX | VB.Net-Tipps | Chat | Spielplatz | Links | Suchen | Stichwortverzeichnis | Feedback | Impressum

Seite empfehlen Bug-Report
Letzte Aktualisierung: Dienstag, 9. August 2011