Author Topic: Padding Characters to BasicLabel  (Read 2535 times)

madmaxed

  • Newbie
  • *
  • Posts: 8
    • View Profile
Padding Characters to BasicLabel
« on: March 25, 2015, 03:10:57 PM »
I've already done it for non-scaled values to add left padding.  This allows for keeping a fixed amount of digits or characters for any value.
    '**********************************
    '* Padding to text
    '**********************************
    Private m_ValuePadCharacter As Char
    Public Property ValuePadCharacter() As Char
        Get
            Return m_ValuePadCharacter
        End Get
        Set(ByVal value As Char)
            m_ValuePadCharacter = value
            UpdateText()
            Invalidate()
        End Set
    End Property
    Private m_ValuePadLength As Integer
    Public Property ValuePadLength As Integer
        Get
            Return m_ValuePadLength
        End Get
        Set(ByVal value As Integer)
            m_ValuePadLength = value
            UpdateText()
            Invalidate()
        End Set
    End Property

Changed UpdateText method
                If m_ValueScaleFactor = 1 Then
                    If ValuePadLength > 0 Then
                        MyBase.Text = m_Prefix & m_Value.PadLeft(ValuePadLength, ValuePadCharacter) & _Suffix
                    Else
                        MyBase.Text = m_Prefix & m_Value & _Suffix
                    End If
                Else
                    Try
                        MyBase.Text = Value * m_ValueScaleFactor & _Suffix
                    Catch ex As Exception
                        DisplayError("Scale Factor Error - " & ex.Message)
                    End Try
                End If


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5267
    • View Profile
    • AdvancedHMI
Re: Padding Characters to BasicLabel
« Reply #1 on: March 26, 2015, 09:08:23 PM »
I made this as part of the BasicLabel in version 3.98c

madmaxed

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Padding Characters to BasicLabel
« Reply #2 on: March 27, 2015, 08:04:54 AM »
Glad I could contribute.  I'm going to post another idea, in addition to the events for the multistate indicator.