1 1 1 1 1 1 1 1 1 1 Rating 0.00 (0 Votes)

Problemstellung:

Für 32Bit und 64Bit Office Versionen

Wie kann ich einen Long-Farbwert in RGB-Farbwerte umrechnen?

Lösung:
Folgende Funktion in ein öffentliches Modul kopieren:

Public Enum eRGBParts
     rgbRed = 1
     rgbGreen = 2
     rgbBlue = 3
 End Enum
 
Public Function GetRGBValue( _
     ByVal lngColor As Long, _
     ByVal lngRGB As eRGBParts) As Integer
 
    Select Case lngRGB
         Case 1 'Rot
             GetRGBValue = lngColor And &HFF&
         Case 2 'Grün
             GetRGBValue = lngColor \ &H100& And &HFF&
         Case 3 'Blau
             GetRGBValue = lngColor \ &H10000 And &HFF&
     End Select
 End Function

Aufruf:

MsgBox "Rot:" & GetRGBValue(8454143, rgbRed) & vbNewLine _
     & "Grün: " & GetRGBValue(8454143, rgbGreen) & _
     vbNewLine & "Blau: " & GetRGBValue(8454143, rgbBlue)

Ergebnis:


 

Ähnliche Artikel