How to change color of a button


I’ve tried all of the following code and nothing works… what am I doing wrong?

There are 2 buttons (Bootstrap) on screen…
AppStudio v…

Function Button1_onclick()
'Dim VarRed
’Dim VarGreen
’Dim VarBlue
’VarRed = FuRandom(0,256)
'VarGreen = FuRandom(0,256)
'VarBlue = FuRandom(0,256)
'Button1.backgroundColor = RGB(VarRed,VarGreen,VarBlue) 'doesn’t work
Button1.backgroundColor = “Red” 'doesn’t work
End Function

Function FuRandom(VarLowRange,VarHighRange)
Dim x,VarLowRange,VarHighRange
If VarLowRange > VarHighRange Then
MsgBox(“Low range must be less than or equal to high range”,0,"")
x = Rnd
FuRandom = Int((x * (VarHighRange + 1 - VarLowRange)) + VarLowRange)
End If
End Function

Function Button2_onclick()
'Button1.backgroundColor = “Red” 'and this doesn’t work
Button1.background = “Red” 'and this doesn’t work
End Function


SOLVED: Must add “style”… = “Red” works while Button1.backgroundColor = “Red” does NOT work.



changing the color of a button at runtime did not work for me too.

my workaround for setting buttons to green or red :

If …condition… Then ButtonOLR.appearance = “btn-success” Else ButtonOLR.appearance = “btn-danger” End If

primary=dark blue
link=pale blue


Alexander… it’s solved… = “whatever”… just add the word “style”… Whatever is name of color, such as “Red” or “rgb(nnn,nnn,nnn)”

closed #5

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.