Results 1 to 7 of 7

Thread: [RESOLVED] Coloring Text after percentage calculation

Threaded View

  1. #1

    Thread Starter
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Resolved [RESOLVED] Coloring Text after percentage calculation

    Hello,

    I'm calculate the persentage between two numbers.
    After the calculation I want that the positive numbers are green and the others red.

    It's working good, but the numbers -0.25 are still green instead of red.
    How can I change that?

    Here's my code for calculation and coloring the text:

    Code:
      Dim C1 As String = TextBox11.Text
            Dim D1 As String = TextBox1.Text
            Dim percentage As Decimal = Val(D1 - C1) / C1 * 100
    
            TextBox16.Text = String.Format("{0:0.00}", percentage) & " " & "%"
    
            If Val(TextBox16.Text) >= 0.00 Then
    
                TextBox16.Font = New Font("Adobe Devanagari", 11.0, FontStyle.Bold)
                TextBox16.ForeColor = Color.DarkGreen
            Else
    
                TextBox16.Font = New Font("Adobe Devanagari", 11.0, FontStyle.Bold)
                TextBox16.ForeColor = Color.Red
               
            End If
    Thanks in advance,
    Last edited by sparrow1; Nov 10th, 2020 at 09:12 AM.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width