Hello To Everyone
I m new in VB . I have start a project of overtime for a company . The company pay the overtime from date 16 to the date 15 of next month.I have put two boxes on visual basic form naming with Label Starting Date and Ending Date.
Now i want that the first box show automatically the starting date 16 of a month to ending date 15 of a next month.
Please let me know about the code by any experience person in detail .
Thanks
Loading
Khan Abrar AhmedPosted May 27, 2014, 12:38 PM
Dim dt As New DateTime(DateTime.Now.Year, DateTime.Now.Month, 16)
Dim dt1 As New DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(1).Month, 15)
lable.text = "From "+ dt +" To "+dt1;
Mohammad IshaqPosted May 27, 2014, 9:03 AM
a little more guide required is it possible that i show it in the following way.i mean to join both the dates in one box such as
From 16-05-2014 To 15-06-2014
Thanks for your nice co-opration
Jignesh TrivediPosted May 27, 2014, 4:49 AM
hi,
you can write your code in page load event
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim dt As New DateTime(DateTime.Now.Year, DateTime.Now.Month, 16)
Dim dt1 As New DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(1).Month, 15)
' Now assign dt value to from date and dt1 value to end date
End Sub
hope this will help you.
Khan Abrar AhmedPosted May 27, 2014, 3:31 AM
DateTime dates = Convert.ToDateTime(DateTime.Now.Month.ToString() + "-16" + "-" + DateTime.Now.Year.ToString());
txtFromDate.Text = dates.ToString("dd-MM-yyyy");
txtToDate.Text = Convert.ToDateTime(dates).AddDays(30).ToString("dd-MM-yyyy");