Results 1 to 3 of 3

Thread: Value Counter User Control

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2017
    Location
    South Africa (in the middle)
    Posts
    160

    Value Counter User Control

    A small value counter:
    Name:  Image 047.png
Views: 987
Size:  373 Bytes

    What's on the form:
    Name:  Image 049.png
Views: 892
Size:  458 Bytes

    What is it?
    Name:  Image 048.png
Views: 1747
Size:  2.9 KB

    The coding:
    Code:
    'Default Property Values:
    Const m_def_Value = 0
    'Property Variables:
    Dim m_Value As Integer
    'Event Declarations:
    Event DownClick(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=ThisCountDown,ThisCountDown,-1,MouseUp
    Event UpClick(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=ThisCountUp,ThisCountUp,-1,MouseUp
    
    Public Property Get Value() As Integer
       Value = m_Value
    End Property
    
    Public Property Let Value(ByVal New_Value As Integer)
       m_Value = New_Value
       PropertyChanged "Value"
       CounterLabel.Text = m_Value
    End Property
    
    Private Sub UserControl_InitProperties()
       m_Value = m_def_Value
       UserControl.Height = ThisCountUp.Height - 20
    End Sub
    
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    
       m_Value = PropBag.ReadProperty("Value", m_def_Value)
       CounterLabel.BackColor = PropBag.ReadProperty("BackColor", &H80000005)
    End Sub
    
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    
       Call PropBag.WriteProperty("Value", m_Value, m_def_Value)
       Call PropBag.WriteProperty("BackColor", CounterLabel.BackColor, &H80000005)
    End Sub
    
    Public Property Get BackColor() As OLE_COLOR
       BackColor = CounterLabel.BackColor
    End Property
    
    Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
       CounterLabel.BackColor() = New_BackColor
       PropertyChanged "BackColor"
    End Property
    
    Private Sub ThisCountDown_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
       RaiseEvent DownClick(Button, Shift, X, Y)
       CounterLabel.Text = Val(CounterLabel.Text) - 1
       m_Value = Val(CounterLabel.Text)
    
    End Sub
    
    Private Sub ThisCountUp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
       RaiseEvent UpClick(Button, Shift, X, Y)
       CounterLabel.Text = Val(CounterLabel.Text) + 1
       m_Value = Val(CounterLabel.Text)
    End Sub
    The user can enlarge the textbox size manually or add code to it, as well as forecolor which I did not need.

    Project: Value Counter.zip
    Last edited by Inside; Aug 26th, 2017 at 04:58 AM. Reason: Adding Project
    Programmers are very patient people....while programming....but don't expect them to be patient all the time

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width