SLIDER based date month

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

SLIDER based date month

Post by sal21 »

in vb6 classic. please

I need to add a slider in form tath automaticlly set the step min and max based the number of day of current month is this possible?

and.... during move the cursor, automaticlly, show in a label the value of day of current idex of cursor

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SLIDER based date month

Post by HansV »

Let's say you have a scroll bar ScrollBar1 and a label Label1.

In the On Load event of the form, to initialize the scroll bar:

Code: Select all

Private Sub Form_Load()
    With Me.ScrollBar1
        .Min = 1
        .Max = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
        .Value = Day(Date)
    End With
End Sub
In the On Change event of the scroll bar:

Code: Select all

Private Sub ScrollBar1_Change()
    Me.Label1.Caption = Me.ScrollBar1.Value
End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: SLIDER based date month

Post by sal21 »

HansV wrote:Let's say you have a scroll bar ScrollBar1 and a label Label1.

In the On Load event of the form, to initialize the scroll bar:

Code: Select all

Private Sub Form_Load()
    With Me.ScrollBar1
        .Min = 1
        .Max = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
        .Value = Day(Date)
    End With
End Sub
In the On Change event of the scroll bar:

Code: Select all

Private Sub ScrollBar1_Change()
    Me.Label1.Caption = Me.ScrollBar1.Value
End Sub
Sorry but not SCROLLBARR but a SLIDERBAR

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SLIDER based date month

Post by HansV »

I don't have the slider control since I don't have VB6, but it should work EXACTLY the same as a scroll bar. Simply use the name of the slider control instead of ScrollBar1.
Best wishes,
Hans