date & spinbutton problem

colinharwood

Active Member
Joined
Jul 27, 2002
Messages
426
Office Version
  1. 2019
Platform
  1. Windows
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
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try changing the Windows Settings/Regional/Date short date format.
 
Upvote 0
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")
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,817
Members
449,049
Latest member
cybersurfer5000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top