Red background textbox if negative

Solved
surplus Posted messages 673 Registration date   Status Member Last intervention   -  
surplus Posted messages 673 Registration date   Status Member Last intervention   -
Hello,
I would like to set the background of a textbox to red if the value is negative
I tried this formula unsuccessfully
sit_compte = Format(sit_compte, "#,##0.00_ ;[Red]-#,##0.00"" €")

how should I proceed, I have been looking for an hour and I am stuck
thank you for your help
--
Best regards, see you soon
Surplus

3 answers

  1. lynyrd1960 Posted messages 233 Status Member 245
     
    Hello forum, surplus
    It can be done with a "class module"
    A+
    0
    1. surplus Posted messages 673 Registration date   Status Member Last intervention   4
       
      hello
      yes but how?
      I've never used a class module
      see you +
      0
  2. Gyrus Posted messages 3360 Status Member 526
     
    Hello,

    Try with this event procedure
    Private Sub TextBox1_Change()
    If TextBox1.Value < 0 Then
    TextBox1.BackColor = RGB(255, 0, 0)
    Else
    TextBox1.BackColor = RGB(255, 255, 255)
    End If
    End Sub
    See you!
    0
  3. surplus Posted messages 673 Registration date   Status Member Last intervention   4
     
    Hello
    it's perfect
    thank you very much
    I hadn't thought of that solution
    Best regards See you soon
    Surplus
    0