i have tried several ways, but i always get an overflow error :(
how can i combine the ARGB color elements?

Public Function ARGB(ByVal alpha As Byte, ByVal red As Byte, ByVal green As Byte, ByVal blue As Byte) As Long


    Dim color As Variant

    color = CDec(alpha) * 256 ' Alpha
    color = (color * 256) + CDec(red) ' Red
    color = (color * 256) + CDec(green) ' Green
    color = CDec((color * 256) + CDec(blue)) ' Blue 

    ARGB = CDec(color) 'overflow error
End Function

Recommended Answers

All 2 Replies

i was avoiding the overflow.... but the problem is much more than the data type... and it's only on Alpha element... but finally seems fixed:

Public Function ARGB(ByVal alpha As Byte, ByVal red As Byte, ByVal green As Byte, ByVal blue As Byte) As Long
    '1st testing the Alpha element:
    ARGB = (alpha And &H7F) * &H1000000 Or -((alpha And &H80) <> 0) * &H80000000 _
        Or red * &H10000 _
        Or green * &H100& _
        Or blue
End Function

thank you so much for all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.