Showing results for 
Search instead for 
Did you mean: 

Change Edit Box Control Backcolor Briefly

Go to solution



I have an apparently simple problem that I cannot solve in the dialog box editor. I have a button and an editbox control on a dialog box and all that is required is that when the button is pressed some text should appear in the editbox and the editbox backcolor should change briefly to another colour before then reverting back. On the basis that the lines of code that change the backcolor will be executed very quickly I have tried to use Pause() just to hold the backcolor for a moment before changing back. However, what seems to happen is the pause is executed before the colour change, so no colour changes are seen. The code is:


Sub Btn_SPAD_EventClick(ByRef This) 'Created Event Handler
  EditBox1.Text = "SPAD"
  EditBox1.BackColor = RGB(95,153,240)
  EditBox1.BackColor = -1
End Sub


I have tried various insertions to refresh the textbox or the dialog itself but to no avail. I have also put the Pause in other Subs, like the editbox change or refresh events but also to no avail.


How do I get the backcolor to change briefly before reverting back?




0 Kudos
Message 1 of 3

Hi Simon_Aldworth,


Please try the attached SUD.




0 Kudos
Message 2 of 3
Accepted by topic author Simon_Aldworth

Thanks Walter. As it happens I managed to find a solution, but I avoided using Pause as that seemed to be causing the problem for me. I found that whenever I used Pause it would interfere with other lines in the same sub, that is to say, the lines didn't seem to execute in order. I used the following in the end:


Sub Btn_StrEquip_EventClick(ByRef This) 'Created Event Handler
  Test = "Steering Equipment"
End Sub

Sub SetTest(Test)
  Text1.Text = Test
  Text1.BackColor = RGB(95,153,240)
  xStart = Timer
  Do Until Timer > xStart + 0.3
  Text1.BackColor = -1
End Sub


The separate function is irrelevant. I have many buttons on the form all doing similar things so I separated out the function to change the text and backcolour.



Message 3 of 3