Determine Date by subtracting days from Current Date dynamically from TextBox

baijuep
 
on Jan 17, 2013 09:35 AM
1912 Views

in my asp.net_vb code web. there are 9 textboxes whih is used for entering numericals/dates

first is lve.text in whicj numder is entered

second one is lvefrom.text

thirdone is lveto.text

when user fills (lve.text) 5 and enter 15 Jan 2013 in lvefrom.text then lveto.text should show 19 Jan 2013. i had posted this earlier and got reply which is mentioned below. this code below gives me 20 Jan 2013 instead of 19 Jan 2013.


tow text boxes lve.text (number filled)  and lvefrom.text (date filled). when user enter a numder in lve.text and select a date fro date picker in lvefrom.text then lveto.text should show date selected in lvefrom.text + number of days in lveto.text (eg if number of days is 5 and date selected in lvefrom.text is 15 Jan 2013 then lveto.text should display 19 jan 2013. because the satrting day is also counted in my case.

Protected Sub lvefrom_TextChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvefrom.TextChanged
        Dim ObjLocDate As New Date
        Dim IntLocDays As Integer
        IntLocDays = Convert.ToInt32(lve.Text)
        ObjLocDate = lvefrom.Text
        ObjLocDate = ObjLocDate.AddDays(IntLocDays)
        lveto.Text = ObjLocDate.Date.ToString("dd-MMM-yyyy")
    End Sub

fourt tex box is pfx.text, fifth is pfx1.text, sixth is pfx2.text

when use filles pfx.text 3 then pfx1.text should display 12 Jan 2013 and pfx2.text should display 14 Jan 2013. these are the prefix for leave( as 12 to 14 Jan 2013 is prefix

seveth is sfx.text, eighth is sfx1.text and nineth is sfx2.text

when user fills sfx.text then sfx1.text should display 20 Jan 2013 and sfx2.text should display  22 Jan 2013 these are the suffix for the leave.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mustafa
 
on Jan 19, 2013 12:59 AM

Ok you can do this and it will work

IntLocDays = Convert.ToInt32(lve.text)
ObjLocDate = lvefrom.Text
ObjLocDate = ObjLocDate.AddDays(IntLocDays)
sfx1.text = ObjLocDate.Date.ToString("dd-MMM-yyyy")
IntLocDays = Convert.ToInt32(sfx.text)
IntLocDays = IntLocDays - 1
ObjLocDate = ObjLocDate.AddDays(IntLocDays)
sfx2.text = ObjLocDate.Date.ToString("dd-MMM-yyyy")