Convert Color

SIMIN

Regular
Joined
Mar 10, 2008
Messages
92
Hello,
Colors are different in VB.NET and VB6.
For example, the background of my form in my VB.NET program is "194, 217, 247" but I cannot use this format for my VB6 application.
So how can I convert "194, 217, 247" to a format which VB6 accepts?
Thanks.
 
IN .NET your 194, 217, 247 = R, G, B

Visual Basic:
' thus
' R = 194
' G = 217
' B = 247

'Visual Basic stores this as a Long (integer)
' this calculation should work
Color = (256 * 256 * B)   + G * 256 + R 

'or the bult-in VB function RGB can calculate the Long value for you 
Color = RGB (R,G,B)
 
Color.ToARGB() should return a 32-bit integer composite value that would be the VB6 equivalent, although the alpha component may have to be filtered out.
 
Last edited:
Back
Top