Add days to a date

K

kk

With three textboxes(1,2 and 3) in a userform1.
If I insert a date in textbox1, how do I get textbox2 to show the date
(textbox1)+90 days and textbox3 to show the date (textbox1)+120 days?
Using vb code?
 
D

Dave Peterson

Option Explicit
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(Me.TextBox1.Value) Then
Me.TextBox2.Value _
= Format(CDate(Me.TextBox1.Value) + 90, "mmmm dd, yyyy")
Me.TextBox3.Value _
= Format(CDate(Me.TextBox1.Value) + 120, "mmmm dd, yyyy")
Else
Beep
Cancel = True
End If
End Sub
 
K

kk

Excellent, brilliant.
Thank you Dave
--
kk


Dave Peterson said:
Option Explicit
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If IsDate(Me.TextBox1.Value) Then
Me.TextBox2.Value _
= Format(CDate(Me.TextBox1.Value) + 90, "mmmm dd, yyyy")
Me.TextBox3.Value _
= Format(CDate(Me.TextBox1.Value) + 120, "mmmm dd, yyyy")
Else
Beep
Cancel = True
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top