|
|
Title | Generate random colors in Visual Basic 6 |
Description | This example shows how to generate random colors in Visual Basic 6. |
Keywords | color, random color, RGB, QBColor |
Categories | Graphics, VB.NET |
|
|
Module RandomColors contains two functions that return random colors. Function RandomQBColor selects a random number between 0 and 15 and returns the corresponding QBColor value.
Function RandomRGBColor randomly generates random red, green, and blue components for a color. It passes them into the RGB function and returns the result.
|
|
' Return a random QB color.
Public Function RandomQBColor() As Long
RandomQBColor = QBColor(Int(Rnd() * 16))
End Function
' Return a random RGB color.
Public Function RandomRGBColor() As Long
RandomRGBColor = RGB( _
Int(Rnd() * 256), _
Int(Rnd() * 256), _
Int(Rnd() * 256))
End Function
|
|
|
|
|
|