|
-
Oct 27th, 2023, 11:16 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Less Then 0 but greater then (negative .5)
Making a traffic light color app and cannot figure out how to handle a negative value ( -0.5) to make a panels BackColor = Color.Yellow
Code:
If CDbl(TxFrontThrustAfter.Text) < 0.0 And CDbl(TxFrontThrustAfter.Text) > -0.5 Then
PnlFrontAfterThrust.BackColor = Color.Yellow
End If
Please see attached image
-
Oct 28th, 2023, 02:26 AM
#2
Re: Less Then 0 but greater then (negative .5)
That code could be improved in various ways but it looks like it should do exactly what you want as it is. What's the actual problem?
-
Oct 28th, 2023, 02:42 AM
#3
Thread Starter
Frenzied Member
Re: Less Then 0 but greater then (negative .5)
thankyou, i am now thinking its due to below in a earlier sub.
Code:
'REMOVES "-" VALUE FROM TEXTBOX
If TxFrontThrustAfter.Text.Contains("-") Then
'MessageBox.Show(TxFThrustBefore.Text)
Dim Str As String = TxFrontThrustAfter.Text
Str = Str.Replace(“-“, “”)
TxFrontThrustAfter.Text = Str
End If
Last edited by toecutter; Oct 28th, 2023 at 03:14 AM.
-
Oct 28th, 2023, 04:04 AM
#4
Re: [RESOLVED] Less Then 0 but greater then (negative .5)
Maybe you should be using a NumericUpDown in the first place, rather than a TextBox.
-
Oct 28th, 2023, 04:07 AM
#5
Re: [RESOLVED] Less Then 0 but greater then (negative .5)
Also, I'm not sure whether this is appropriate in your context but you might consider a Select Case to determine the colour:
Code:
Dim x As Double
Select Case x
Case Is >= 0.2
Case Is >= 0.0
Case Is >= -0.5
Case Else
End Select
-
Oct 28th, 2023, 04:18 PM
#6
Thread Starter
Frenzied Member
Re: [RESOLVED] Less Then 0 but greater then (negative .5)
 Originally Posted by jmcilhinney
Also, I'm not sure whether this is appropriate in your context but you might consider a Select Case to determine the colour:
Code:
Dim x As Double
Select Case x
Case Is >= 0.2
Case Is >= 0.0
Case Is >= -0.5
Case Else
End Select
this would be perfect, thx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|