By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

how to conditional formatting a value in a text box

P: 1
hi guys'
i'm trying to get a different color for each range of values calculated on my calculator,

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  2.         'calculate fome precentage, write to text box 3
  3.  
  4.         Dim intdry As Double
  5.         Dim intwet As Double
  6.         Dim intfoam As Double
  7.  
  8.  
  9.  
  10.         intdry = (Val(dry.Text))
  11.         intwet = (Val(wet.Text))
  12.  
  13.         'calculation equation 
  14.         intfoam = (1 - (intdry / ((intdry + intwet) * 0.956))) * 100
  15.  
  16.         foam.Text = intfoam
  17.  
  18.  
  19.         'conditional formating - color textbox good/warning/bad
  20.  
  21.         Dim bad As Integer
  22.         Dim warning As Integer
  23.         Dim good As Integer
  24.  
  25.  
  26.         good = (Val(11 - 14.99))
  27.  
  28.         bad = (Val(16 - 30) Or (Val(8.49 - 0.1)))
  29.  
  30.         warning = (Val(15 - 15.99) Or (Val(8.5 - 10.99)))
  31.  
  32.  
  33.  
  34.  
  35.  
  36.         If foam.Text = good Then
  37.             foam.BackColor = Color.LimeGreen()
  38.  
  39.         ElseIf foam.Text = bad Then
  40.             foam.BackColor = Color.Red()
  41.  
  42.         ElseIf foam.Text = warning Then
  43.             foam.BackColor = Color.Orange()
  44.  
  45.         End If
  46.  
  47.  
  48.     End Sub
i'm not getting any color that way, unless i'm using < or>, dose any of you have an idea how to solve it?
tnx roy.
Mar 7 '15 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.