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,184
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,845
Messages
5,361,665
Members
400,643
Latest member
RockStar89

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top