EDN Admin
Well-known member
Hi,
I am working on a time tracking application and i am findinf the due date based on the start date.I got a code to find this in excel vba. Below is the code for your reference
<br/>
<pre class="prettyprint lang-vb Sub two()
Dim duration As Variant: Dim startdate As Variant: Dim enddate As Variant
duration = TimeSerial(8, 0, 0): MsgBox "Duration : " & duration
Range("b4").Value = duration
Dim s As String: s = InputBox("Enter date and time in dd-mm-yyyy hh:mm:ss format", "Datetime", "1-1-2012 9:0:0")
startdate = CDate(s): MsgBox startdate: MsgBox "start : " & Format(startdate, "mm/dd/yyyy hh:nn:ss")
Range("b5").Value = Format(startdate, "mm/dd/yyyy hh:nn:ss")
Dim dt As Long: dt = CLng(WorksheetFunction.RoundDown(startdate, 0)): MsgBox "date : " & Format(dt, "mm/dd/yyyy hh:nn:ss")
If startdate > (dt + TimeSerial(18, 0, 0)) Then
exhausted = 0
enddate = (dt + 1) + TimeSerial(9, 0, 0) + duration
ElseIf (startdate + duration) > (dt + TimeSerial(18, 0, 0)) Then
exhausted = dt + TimeSerial(18, 0, 0) - startdate
enddate = (dt + 1) + TimeSerial(9, 0, 0) + (duration - exhausted)
ElseIf startdate <= (dt + TimeSerial(10, 0, 0)) Then
exhausted = TimeSerial(8, 0, 0)
enddate = startdate + duration
End If
MsgBox "EndDate : " & enddate
End Sub[/code]
<br/>
This code is working perfectly in excel. since my application is being done in vb.net, i dont know how to change this code to vb.net
Can anyone help me in doing this.
<hr class="sig Thanks you and Kind Regards, Karthik Venkatraman
View the full article
I am working on a time tracking application and i am findinf the due date based on the start date.I got a code to find this in excel vba. Below is the code for your reference
<br/>
<pre class="prettyprint lang-vb Sub two()
Dim duration As Variant: Dim startdate As Variant: Dim enddate As Variant
duration = TimeSerial(8, 0, 0): MsgBox "Duration : " & duration
Range("b4").Value = duration
Dim s As String: s = InputBox("Enter date and time in dd-mm-yyyy hh:mm:ss format", "Datetime", "1-1-2012 9:0:0")
startdate = CDate(s): MsgBox startdate: MsgBox "start : " & Format(startdate, "mm/dd/yyyy hh:nn:ss")
Range("b5").Value = Format(startdate, "mm/dd/yyyy hh:nn:ss")
Dim dt As Long: dt = CLng(WorksheetFunction.RoundDown(startdate, 0)): MsgBox "date : " & Format(dt, "mm/dd/yyyy hh:nn:ss")
If startdate > (dt + TimeSerial(18, 0, 0)) Then
exhausted = 0
enddate = (dt + 1) + TimeSerial(9, 0, 0) + duration
ElseIf (startdate + duration) > (dt + TimeSerial(18, 0, 0)) Then
exhausted = dt + TimeSerial(18, 0, 0) - startdate
enddate = (dt + 1) + TimeSerial(9, 0, 0) + (duration - exhausted)
ElseIf startdate <= (dt + TimeSerial(10, 0, 0)) Then
exhausted = TimeSerial(8, 0, 0)
enddate = startdate + duration
End If
MsgBox "EndDate : " & enddate
End Sub[/code]
<br/>
This code is working perfectly in excel. since my application is being done in vb.net, i dont know how to change this code to vb.net
Can anyone help me in doing this.
<hr class="sig Thanks you and Kind Regards, Karthik Venkatraman
View the full article