date & spinbutton problem

colinharwood

Active Member
Joined
Jul 27, 2002
Messages
343
Hi

I have a textbox on a userform which is populated by a date in the format dd/mm/yy, from a worksheet, when the userform is initialised.

The following code is then used to increase or decrease the date as required.

'This procedure decrements the date shown in
'TextBox1 when you decrease the value of the
'SpinButton.

Private Sub SpinButton1_SpinDown()
On Error GoTo errortrap
DateSpin.Text = DateValue(DateSpin.Text) - 1

errortrap: Exit Sub
End Sub

'This procedure increments the date shown in
'TextBox1 when you increase the value of the
'SpinButton.

Private Sub SpinButton1_SpinUp()
On Error GoTo errortrap
DateSpin.Text = DateValue(DateSpin.Text) + 1

errortrap: Exit Sub

End Sub


This has worked for many months, but having just reinstalled windows, and I now find that when I alter the date using the spinbutton the format in the textbox changes to dd/mm/yyyyy.

Anybody got any ideas why this now happens?

Regards

Colin
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,177
Try changing the Windows Settings/Regional/Date short date format.
 

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
Could be to do with Windows settings. Check Control Panel.

Otherwise I think this will solve the problem
Code:
DateSpin.Text = Format(DateValue(DateSpin.Text) + 1, "dd/mm/yy")
 

colinharwood

Active Member
Joined
Jul 27, 2002
Messages
343
Thanks for the replies guys, Glenn was right, changed the setting and all is fine.

I thought it must be something in the Windows settings but my mind had gone blank after playing about with loads of settings in Excel.

Regards

Colin
 

Forum statistics

Threads
1,081,513
Messages
5,359,226
Members
400,521
Latest member
smarty1995

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top