0

I want to do something like counting date, it's truly like this
First I click on one date time picker which called 'dtpstart'. Then I typed number of dates on text box called 'period'. After that I want to show what is the date ?
For Ex:
dtpstart = 2016.01.01
period = 10
lastdate = 2016.01.11
I want to get this last date to label.
Currently I'm trying this code : but It doesn't work.

Dim datestart As Date
        datestart = dtploanstart.Value
        Dim i As Integer
        For i 1 to 65
            datestart = dtploanstart.Value.AddDays(1)
        Next
        datestart = dtploanend.Value

can anyone help ?

3
Contributors
4
Replies
20
Views
11 Months
Discussion Span
Last Post by AleMonteiro
0

I didn't understand why you got a For loop... This should work (i assumed you got an txtPeriod for entering the date)

Dim dtStart As Date = dtploanstart.Value
Dim intPeriod as Integer = CInt(txtPeriod.Text)
Dim dtEnd = dtStart.AddDays(intPeriod);
0

A little addition with AleMonteiro's post you can also use DateAdd() fuction to get your desired date.
The syntax is
DateAdd(DateInterval As Microsoft.VisualBasic.DateInterval,Number As Double,DateVAlue As Date)

 LabelEndDate.Text = DateAdd(DateInterval.Day, Val(TextBox1.Text), dtploanstart.Value)

Edited by Shark_1

0

thank you sir I got idea :)
what ever can I skiped some days from counting this days....
I mean skiping holidays

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.