Creating Rainbow Text
This week I will show you a useful tip that is very simple to do and very effective.
You may have seen programs that have multicoloured (Rainbow) text in the background.
Well this is very simple to do using a for loop.
Code
1. Start a new Standard Exe project; form1 is created by default
2. Type in the following code. Sub Form_Paint()
Dim I As Integer, X As Integer, Y As Integer
Dim C As String
Cls
For I = 0 To 91
X = CurrentX
Y = CurrentY
C = Chr(I)
'Line -(X + TextWidth(C), Y = TextHeight(C)), _
QBColor(Rnd * 16), BF
CurrentX = X
CurrentY = Y
ForeColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
Print "Hello World Hello World Hello World Hello"
Next
End Sub
3. Run the program by pressing F5 or choosing start from the run program and watch the
form fill with lots of multi-coloured text
|