>I have a form which has about 30 text boxes which I want to color code. So for the "forecolor" property I want to simply say something like "f_color(this.value)" instead of defining a specific color. the function f_color would do some calculation and would return a color such as red.
>
>so thisform.text1.ForeColor= f_color(this.value) works well but i am getting a type error if the color returned is "50,50,50". if i do a VAL on the color as in thisform.text1.ForeColor= val(f_color(this.value)), it works but does not return the color i want. how, and in what format, do i return the correct color?
Just make sure that the f_color function returns a RGB number. I.e. the function should not return "50,50,50" but rather Rgb(50,50,50). Such numbers are actually integers, and if you want to avoid always calling the rgb() function (although it is very fast), you may use the numbers themselves. One shortcut to these numbers would be to use their hex representation - RGB(50,50,50) is equal 0x00323232, but keep in mind that the order of the colors in these numbers is actually BGR, so RGB(1,128,255) equals 0x00ff8001.