I have a form has to (maskedbox1) and (maskedbox2)
if maskedbox1 I put date of today, I want (maskedbox2) show date after 30 days as defult
I will be thank you if you help me to do this
I use vb6

Recommended Answers

All 4 Replies

To calculate after 30 days you can use DateAdd() function

Example

Draw two MaskEdit Controls and One Command Button

Private Sub Command1_Click()
   Dim FormatDate As String
   Dim DateAfter30Days  As Date
   
   DateAfter30Days = CDate(MaskEdBox1.Text)
   DateAfter30Days = DateAdd("d", 30, DateAfter30Days)
   FormatDate = Format(DateAfter30Days, "dd/MM/yy")
   MaskEdBox2.Text = FormatDate

End Sub

Private Sub Form_Load()
   MaskEdBox1.Mask = "##/##/##"
   MaskEdBox2.Mask = "##/##/##"
   MaskEdBox1.Text = Format(Date, "dd/MM/yy")
End Sub

selvaganapathy was given great code...
also you can try use DateSerial()
DateSerial(Year,Month,Day)
This will add 20 days from 5 July 2008.

Private Sub Form_Load()
MsgBox DateSerial(2008, 7, 5 + 20)
End Sub

Result : 7/25/2008

This will count the 50 days from 1 July 2008.

Private Sub Form_Load()
MsgBox DateSerial(2008, 7, 50)
End Sub

Result : 8/19/2008

Thank Mr. selvaganapathy
I have another quition:
can I use paper A5 with datereport?

I think, we cannot set paper A5. but you can ReportWidth property. i dont think it will be A5 size.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.