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,044
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,078,471
Messages
5,340,514
Members
399,381
Latest member
impurnasekar

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top