Date buttons

Hi
I have a date displayed in a text box
i then have 2 command buttons.
Saying forward and back
if the user presses the forward date button it will increment the date by 1 and so on and the same for the back button. It must automatically be able to move from one month to the next
my date format is yyyy/mm/dd

thanx allot

Craig
LVL 4
CraigLazarAsked:
Who is Participating?
 
abaldwinConnect With a Mentor Commented:
I believe this is what you are looking for.

For this demo I have
1 text box   Text1
2 Command buttons  Command1 and Command2

Private Sub Command1_Click()
    Text1.Text = Format(DateAdd("d", 1, Text1.Text), "YYYY/MM/DD")
   
End Sub

Private Sub Command2_Click()
    Text1.Text = Format(DateAdd("d", -1, Text1.Text), "YYYY/MM/DD")
End Sub

This code should probably be modified to first check for a valid date in the text box etc.

Hope that helps.

Andy
0
 
sunil27Commented:
Just a suggestion:
You might wanna consider using the DateTimePicker control in VB for this purpose.
0
 
CraigLazarAuthor Commented:
Thanx allot for the help it was perfect

:)

Craig
0
 
abaldwinCommented:
Your welcome.


0
All Courses

From novice to tech pro — start learning today.