I was wondering if there was a component that would allow me to convert an integer value (seconds) into hrs: mins: sec: on advanced HMI. I'm not seeming to find one. if there is not one, is there a way to develop my own? I'm not the best at coding...but im sure there is already code online for this feature. I just do not know how to input the code and make a component out of it.
I did a project that needed to display a value in hh:mm format. I made some minor modifications to the BasicLabel like this:
In Solution Explorer, expand down the AdvancedHMIControls project and expand down the Controls folder. Right click BasicLabel.vb and select View Code. Then make these changes:
In the Basic Properties Region, add this code:
Private m_DisplayAsTime As Boolean
Public Property DisplayAsTime As Boolean
Get
Return m_DisplayAsTime
End Get
Set(value As Boolean)
m_DisplayAsTime = value
End Set
End Property
In the Private Methods Region, find the Private Sub UpdateText. Go down until you find End Sub. Insert the code as shown here:
If m_DisplayAsTime Then
Try
If Value <> "" And Not Me.DesignMode Then
Dim Hours As Double
Hours = CDbl(Value) * m_ValueScaleFactor
Dim Minutes As Double = (Hours - Math.Floor(Hours)) * 60
ResultText = Math.Floor(Hours) & ":" & Format(Math.Floor(Minutes), "00")
End If
Catch ex As Exception
MyBase.Text = ex.Message
Exit Sub
End Try
End If
MyBase.Text = ResultText
End Sub
You will need to modify the code if you want hh:mm:ss