Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1449

Value Counter User Control

$
0
0
A small value counter:
Name:  Image 047.png
Views: 25
Size:  373 Bytes

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

What is it?
Name:  Image 048.png
Views: 23
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.
Attached Images
   

Viewing all articles
Browse latest Browse all 1449

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>