Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 14th, 2005, 8:03 AM   #1
Sniper
Newbie
 
Join Date: Mar 2005
Posts: 1
Rep Power: 0 Sniper is on a distinguished road
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
Sniper is offline   Reply With Quote
Old Apr 2nd, 2005, 8:28 AM   #2
PhaseR
Newbie
 
Join Date: Mar 2005
Posts: 2
Rep Power: 0 PhaseR is on a distinguished road
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)];
PhaseR is offline   Reply With Quote
Old Oct 30th, 2005, 6:04 AM   #3
Meka][Meka
Newbie
 
Join Date: Oct 2005
Posts: 6
Rep Power: 0 Meka][Meka is on a distinguished road
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));
__________________
']['€AM€LiT€

Meka-Meka Programming Forums
Meka][Meka is offline   Reply With Quote
Old Oct 30th, 2005, 10:50 PM   #4
ekamaloff
Newbie
 
Join Date: Oct 2005
Posts: 3
Rep Power: 0 ekamaloff is on a distinguished road
It would be better :

Randomize;
lblColour.Color := RGB(Random(256),Random(256),Random(256));
ekamaloff is offline   Reply With Quote
Old Nov 1st, 2005, 3:53 AM   #5
Meka][Meka
Newbie
 
Join Date: Oct 2005
Posts: 6
Rep Power: 0 Meka][Meka is on a distinguished road
Quote:
Originally Posted by ekamaloff
It would be better :

Randomize;
lblColour.Color := RGB(Random(256),Random(256),Random(256));
no... there is no such thing as RGB(256,256,256), this is byte sizes not mb of ram etc....255 is highest u can go, 256 is out of bounds....

RGB(255,255,255) = $FFFFFF = clWhite
__________________
']['€AM€LiT€

Meka-Meka Programming Forums
Meka][Meka is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:28 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC