TKSoft-Online

Umrechnen Long-Farbwert in HEX-Farbwert PDF Drucken E-Mail
( 0 Votes )
MS-Access Codes - Codeschnipsel Grafik
  
Freitag, den 02. Mai 2008 um 06:00 Uhr

Problemstellung:

Wie kann ich einen Long-Farbwert  in einen HEX-Farbwert umrechnen?

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


Public Type tRGB
    bytR As Byte
    bytG As Byte
    bytB As Byte
End Type

Public Function Long2Hex( _
    ByVal lngRGBColor As LongAs String

    Dim tmpCol As tRGB
    Dim strR As String
    Dim strG As String
    Dim strB As String

    With tmpCol
        .bytR = lngRGBColor Mod 256
        .bytG = (lngRGBColor \ 256) Mod 256
        .bytB = lngRGBColor \ 65536
    End With

    strR = Trim(Hex(tmpCol.bytR))
    strG = Trim(Hex(tmpCol.bytG))
    strB = Trim(Hex(tmpCol.bytB))

    If Len(strR) = 1 Then strR = "0" & strR
    If Len(strG) = 1 Then strG = "0" & strG
    If Len(strB) = 1 Then strB = "0" & strB

    Long2Hex = "#" & strR & strG & strB

End Function

 

Aufruf:

  MsgBox Long2Hex(12632256)

 

Ergebnis:


DatumKlicks
Total2537
Do. 241
Mi. 232
Di. 222
Mo. 212
So. 201
Sa. 193
Fr. 183
Aktualisiert ( Donnerstag, den 01. Juli 2010 um 12:53 Uhr )
 

Kommentar schreiben


Sicherheitscode
Aktualisieren

Login

Latest Comments

Latest Forum Posts

Mehr »

Download Statistik

41 Kategorien
187 Dateien
173466 Downloads