Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton & Date Format
I would like to use a SpinButton to change the date value held in
TextBox1. Using the follow code in the SpinUp event procedures works ------------------------------ Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(CDate(TextBox1.Text) + 1, "dd mm yyyy") End Sub ------------------------------ But I need to return the date in the form "Monday 21 Dec" with no year ------------------------------ Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub ------------------------------ I would welcome any advice Thanks Phil |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton & Date Format
Phil,
The problem lies with the string your store in Textbox1. Although it looks like a date, it is just a string. I have used a date variable to hold the date, increment that, and display it. like so Dim myDate As Date Private Sub SpinButton1_SpinUp() myDate = myDate + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub Private Sub UserForm_Initialize() myDate = Date + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub -- HTH ------- Bob Phillips wrote in message oups.com... I would like to use a SpinButton to change the date value held in TextBox1. Using the follow code in the SpinUp event procedures works ------------------------------ Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(CDate(TextBox1.Text) + 1, "dd mm yyyy") End Sub ------------------------------ But I need to return the date in the form "Monday 21 Dec" with no year ------------------------------ Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub ------------------------------ I would welcome any advice Thanks Phil |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton & Date Format
Bob
Thanks, That did indead work. I was getting a little frustrated with this problem because I knew I had solved it before, but couldn't remember how. After 4 hours and at 6am UK time I posted my message. Having read your advice I saw what the problem was Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(SpinButton1.Value, "dddd d mmm") End Sub Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub Thanks again Phil Bob Phillips wrote: Phil, The problem lies with the string your store in Textbox1. Although it looks like a date, it is just a string. I have used a date variable to hold the date, increment that, and display it. like so Dim myDate As Date Private Sub SpinButton1_SpinUp() myDate = myDate + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub Private Sub UserForm_Initialize() myDate = Date + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub -- HTH ------- Bob Phillips wrote in message oups.com... I would like to use a SpinButton to change the date value held in TextBox1. Using the follow code in the SpinUp event procedures works ------------------------------ Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(CDate(TextBox1.Text) + 1, "dd mm yyyy") End Sub ------------------------------ But I need to return the date in the form "Monday 21 Dec" with no year ------------------------------ Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub ------------------------------ I would welcome any advice Thanks Phil |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton & Date Format
I see. Should you not also initialise the spinbutton value to today's date +
1 (it is only a number after all. -- HTH ------- Bob Phillips wrote in message oups.com... Bob Thanks, That did indead work. I was getting a little frustrated with this problem because I knew I had solved it before, but couldn't remember how. After 4 hours and at 6am UK time I posted my message. Having read your advice I saw what the problem was Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(SpinButton1.Value, "dddd d mmm") End Sub Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub Thanks again Phil Bob Phillips wrote: Phil, The problem lies with the string your store in Textbox1. Although it looks like a date, it is just a string. I have used a date variable to hold the date, increment that, and display it. like so Dim myDate As Date Private Sub SpinButton1_SpinUp() myDate = myDate + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub Private Sub UserForm_Initialize() myDate = Date + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub -- HTH ------- Bob Phillips wrote in message oups.com... I would like to use a SpinButton to change the date value held in TextBox1. Using the follow code in the SpinUp event procedures works ------------------------------ Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(CDate(TextBox1.Text) + 1, "dd mm yyyy") End Sub ------------------------------ But I need to return the date in the form "Monday 21 Dec" with no year ------------------------------ Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub ------------------------------ I would welcome any advice Thanks Phil |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton & Date Format
Hi Bob,
I am a little surprised but it would seem that setting the SpinButton's Max and Min properties has initialised the control for me. If I REM out these two values clicking SpinDown sets the TextBox to Saturday 30 December (from which point if will not move further down) SpinUp is free to move until the TextBox displays Saturday 9 April Private Sub SpinButton1_SpinDown() TextBox1.Text = Format(SpinButton1.Value, "dddd d mmm") End Sub Private Sub SpinButton1_SpinUp() TextBox 1.Text = Format(SpinButton1.Value, "dddd d mmm") End Sub Private Sub UserForm_Initialize() With SpinButton1 ..Enabled = True ..Max = Date + 7 ..Min = Date End With End Sub Bob Phillips wrote: I see. Should you not also initialise the spinbutton value to today's date + 1 (it is only a number after all. -- HTH ------- Bob Phillips wrote in message oups.com... Bob Thanks, That did indead work. I was getting a little frustrated with this problem because I knew I had solved it before, but couldn't remember how. After 4 hours and at 6am UK time I posted my message. Having read your advice I saw what the problem was Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(SpinButton1.Value, "dddd d mmm") End Sub Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub Thanks again Phil Bob Phillips wrote: Phil, The problem lies with the string your store in Textbox1. Although it looks like a date, it is just a string. I have used a date variable to hold the date, increment that, and display it. like so Dim myDate As Date Private Sub SpinButton1_SpinUp() myDate = myDate + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub Private Sub UserForm_Initialize() myDate = Date + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub -- HTH ------- Bob Phillips wrote in message oups.com... I would like to use a SpinButton to change the date value held in TextBox1. Using the follow code in the SpinUp event procedures works ------------------------------ Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(CDate(TextBox1.Text) + 1, "dd mm yyyy") End Sub ------------------------------ But I need to return the date in the form "Monday 21 Dec" with no year ------------------------------ Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub ------------------------------ I would welcome any advice Thanks Phil |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
SpinButton & Date Format
Private Sub UserForm_Initialize()
With SpinButton1 ..Enabled = True ..Max = Date + 7 ..Min = Date ..Value = Date + 1 End With End Sub -- Regards, Tom Ogilvy wrote in message oups.com... Hi Bob, I am a little surprised but it would seem that setting the SpinButton's Max and Min properties has initialised the control for me. If I REM out these two values clicking SpinDown sets the TextBox to Saturday 30 December (from which point if will not move further down) SpinUp is free to move until the TextBox displays Saturday 9 April Private Sub SpinButton1_SpinDown() TextBox1.Text = Format(SpinButton1.Value, "dddd d mmm") End Sub Private Sub SpinButton1_SpinUp() TextBox 1.Text = Format(SpinButton1.Value, "dddd d mmm") End Sub Private Sub UserForm_Initialize() With SpinButton1 .Enabled = True .Max = Date + 7 .Min = Date End With End Sub Bob Phillips wrote: I see. Should you not also initialise the spinbutton value to today's date + 1 (it is only a number after all. -- HTH ------- Bob Phillips wrote in message oups.com... Bob Thanks, That did indead work. I was getting a little frustrated with this problem because I knew I had solved it before, but couldn't remember how. After 4 hours and at 6am UK time I posted my message. Having read your advice I saw what the problem was Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(SpinButton1.Value, "dddd d mmm") End Sub Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub Thanks again Phil Bob Phillips wrote: Phil, The problem lies with the string your store in Textbox1. Although it looks like a date, it is just a string. I have used a date variable to hold the date, increment that, and display it. like so Dim myDate As Date Private Sub SpinButton1_SpinUp() myDate = myDate + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub Private Sub UserForm_Initialize() myDate = Date + 1 TextBox1.Text = Format(myDate, "dddd d mmm") End Sub -- HTH ------- Bob Phillips wrote in message oups.com... I would like to use a SpinButton to change the date value held in TextBox1. Using the follow code in the SpinUp event procedures works ------------------------------ Private Sub SpinButton1_SpinUp() TextBox1.Text = Format(CDate(TextBox1.Text) + 1, "dd mm yyyy") End Sub ------------------------------ But I need to return the date in the form "Monday 21 Dec" with no year ------------------------------ Private Sub UserForm_Initialize() TextBox1.Text = Format(Date + 1, "dddd d mmm") End Sub ------------------------------ I would welcome any advice Thanks Phil |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Spinbutton | New Users to Excel | |||
Spinbutton | Excel Discussion (Misc queries) | |||
spinbutton? | Excel Programming | |||
Using Spinbutton to change a date | Excel Programming | |||
Change a date in text format xx.xx.20xx to a recognised date format | Excel Programming |