Thursday, February 09, 2017

sssr custom code functions for timestamp, finding max in a row

  Public Function Ms2Str(ms As Int64) As String
        Dim ts As TimeSpan = TimeSpan.FromMilliseconds(ms)
        Dim s As String = String.Format("{0} {1:00}:{2:00}:{3:00}",ts.Days,ts.Hours,ts.Minutes,ts.Seconds)
        Return s
  End Function


    Public Function Sec2Str(sec As Double) As String
        Dim ts As TimeSpan = TimeSpan.FromSeconds(sec)
        Dim s As String = String.Format("{0} {1:00}:{2:00}:{3:00}",ts.Days,ts.Hours,ts.Minutes,ts.Seconds)
        Return s
    End Function

public Function MaxColor(ri as ReportItems, rowNr as integer, colNr as integer, defaultColor as string)

        '1. get value of this cell
        Dim cellName as String
        cellName="c"+rowNr.ToString() +colNr.ToString()
        Dim maxVal=ri(cellName).Value

        '2. check if any other cell has bigger value
        For i As Integer = 0 To 9
            cellName="c"+rowNr.ToString() +i.ToString()
            Dim compare=ri(cellname).Value
            If compare>maxVal Then Return defaultColor   'self not bigger then self
        Next
        '3. No one was bigger => is biggest or equal
        return "LimeGreen"

end Function

No comments: