Page 1 of 1

rando color

PostPosted: Wed Jan 10, 2018 10:44 pm
by Silvio.Falconi
I have an archive where I put a field ncolor ( numeric) to show a color but when I insert a record it is allways black because the fields is empty (0) .
How I can to rando a color different every time I insert a new record ?
Any nice solution ?

I made this
Code: Select all  Expand view
Function Rando_Color(nColor)
   nRed:=HB_Random(0, 255 )
   nBlue:=HB_Random(0, 255 )
   nGia:=HB_Random(0, 255 )
   nColor:= nrgb(nRed,nGia,nBlue)
   msginfo(ncolor)
      return  nColor


but I have often the same or similar color

Re: rando color

PostPosted: Thu Jan 11, 2018 1:48 am
by cnavarro
Try with

Code: Select all  Expand view

   ? Int( 255 * hb_Random( 0, 1 ) ), Int( 255 * hb_Random( 0, 1 ) ), Int( 255 * hb_Random( 0, 1 ) )
 

Re: rando color

PostPosted: Thu Jan 11, 2018 12:16 pm
by Silvio.Falconi
seem run ok I add the search in archive to dbseek any clone