Hi, my problem is, I have set the parameter to be 150 in the database. and the alert triggered should refer to the parameter value. if the calculation result exceeds the parameter value, it will turn the box to red colour. however, i notice that it only compares the first three number. for example, if the calculation result is 1778.99 it will turn the box red because its first three digit is more than 150. but if the calculation result is 10234.90, it does not trigger the alert. i assume it only takes the first three digit. how do i solve this? here is the code for this part;

Dim total1 As Label = CType(e.Item.FindControl("total1"), Label)
        total1.Text = e.Item.DataItem("inventories").ToString * 365 / e.Item.DataItem("operating_cost").ToString
        If total1.Text >= e.Item.DataItem("para1").ToString Then
            total1.BackColor = Drawing.Color.Red
        ElseIf total1.Text <= e.Item.DataItem("para1").ToString Then
            total1.BackColor = Drawing.Color.Transparent
        End If

get those values into integers and compare.

Dim param As Integer = 122
        Dim compval As Integer = Label.Text
        If compval > param Then
            MsgBox("greater")
        Else
            MsgBox("Less")
        End If

This is just sample.. you need to make changes in ur case

hey thanks Pgmer. i've modified the code and it works! :)

here's the modified version of my coding. can be reference for others.

Dim total1 As Label = CType(e.Item.FindControl("total1"), Label)
        total1.Text = e.Item.DataItem("inventories").ToString * 365 / e.Item.DataItem("operating_cost").ToString
        Dim compval As Double = total1.Text
        Dim param As Double = e.Item.DataItem("para1").ToString
        If compval >= e.Item.DataItem("para1").ToString Then
            total1.BackColor = Drawing.Color.Red
        Else
            total1.BackColor = Drawing.Color.Yellow
        End If
Dim total1 As Label = CType(e.Item.FindControl("total1"), Label)
        total1.Text = e.Item.DataItem("inventories").ToString * 365 / e.Item.DataItem("operating_cost").ToString
        Dim compval As Double = total1.Text
        Dim param As Double = e.Item.DataItem("para1").ToString
        If compval >= e.Item.DataItem("para1").ToString Then
            total1.BackColor = Drawing.Color.Red
        Else
            total1.BackColor = Drawing.Color.Transparent
        End If

how to make the Ctype to Cdbl syntax ?
for example 123.324355 convert to 123.32

Use math.round method u can pass how many digits you want to show.
And from next time, plz mark thread as solved and create new for new Query..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.