dollarWon := 100
"(" <> Style["$" <> ToString[dollarWon], If[dollarWon >= 0, Darker[Green], Red]] <> ")"
I am getting an error: String expected at position 2. Isn't it possible to use Style in the above expression?
Thanks.
Style[..] is not a string. Convert it to string by using StandardForm format to preserve style information:
dollarWon := 100
"(" <> ToString[
Style["$" <> ToString[dollarWon],
If[dollarWon >= 0, Darker[Green], Red]], StandardForm] <> ")"
I think you may be better of using Row
in this case, which lets you show arbitrary objects in a row, like so:
dollarWon = 100
Row[{
"(",
Style[
"$" <> ToString[dollarWon],
If[dollarWon >= 0, Darker[Green], Red]
],
")"
}]