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
Im having trouble getting this function to work. I followed your instructions and my output is just the plc value that the hmi is receiving ("4500" counting down) and then ":00" . I dont mean for you to do my work for me, but some advice would be much appreciated. If i have not said this yet, I am a huge newb to programming, but I do see in your code that you have "00" in your private methods part...should this not be a variable instead?