Red background textbox if negative

Solved
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

  • Votes
  • Date
  • Descending date
  1. Hello forum, surplus
    It can be done with a "class module"
    A+
    1. hello
      yes but how?
      I've never used a class module
      see you +
  2. 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!
    1. Hello
      it's perfect
      thank you very much
      I hadn't thought of that solution
      Best regards See you soon
      Surplus