![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2005
Posts: 1
Rep Power: 0
![]() |
random text in delphi
I need some sample code so I can creat a random script which randomizes 2 or more text strings.
I know you can use "random(5)" to get a random number from 0 to 4 but not sure how I can use text! the reason I want to do this is because I want to change the text colour of a lbl between 3 different colours. thanks
__________________
Do you need computer help? then visit Hardware Forums - Zone 365 Love Gadgets? so do we! Visit Gadget Forums |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Mar 2005
Posts: 2
Rep Power: 0
![]() |
it's simple. you can use random for numbers, so you can create an array with all the colours and then chose between them using random.
var a:array[0..10] of string; ... a[0] = 'clWhite'; a[1] = 'clBlack'; a[2] = 'clRed'; a[3] = 'clBlue'; ... mylabel.color = a[random(3)]; |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Oct 2005
Posts: 6
Rep Power: 0
![]() |
and if you want to go deeper into colourizing, you can use RGB, you could even define a set number of colours in an array using the RGB method
Randomize; lblColour.Color := RGB(Random(255),Random(255),Random(255)); |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Oct 2005
Posts: 3
Rep Power: 0
![]() |
It would be better
:Randomize; lblColour.Color := RGB(Random(256),Random(256),Random(256)); |
|
|
|
|
|
#5 | |
|
Newbie
Join Date: Oct 2005
Posts: 6
Rep Power: 0
![]() |
Quote:
RGB(255,255,255) = $FFFFFF = clWhite |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|