--> Skip to main content
Pelajar Koding

follow us

Vb.Net: Dateadd Menambah Hari Hanya Dengan Hari Kerja

Rani pernah diskusikan gimana cara menghitung selisih waktu hari kerja , alasannya ada pertanyaan dari reader gimana klo menyertakan jumlah hari tapi cuma dengan hari kerja saja (weekdays). Langsung aja kita jawab dengan contoh ya. Design UI: Code: Public Class Form1     Private Sub Form1_Load( ByVal sender As System.Object, _             ByVal e As System.EventArgs) Handles MyBase .Load         Label1.Text = "From:"         Label2.Text = "Add day(s):"         Label3.Text = "To:"         Button1.Text = "Add Weekday"     End Sub     Public Shared Function AddWeekdays( ByVal startDate As Date , _                            ByVal interval As Integer ) As Date         Dim curDate As Date = startDate         Dim i As Integer = 0         Do While i             curDate = curDate.AddDays(1)             If curDate.DayOfWeek <> DayOfWeek.Saturday And _                curDate.DayOfWeek <> DayOfWeek.Sunday Then                 i = i + 1             End If         Loop         Return curDate     End Function        Private Sub Button1_Click( ByVal sender As System.Object, _                 ByVal e As System.EventArgs) Handles Button1.Click         DateTimePicker2.Value = AddWeekdays(DateTimePicker1.Value, _                                             CDbl (TextBox1.Text))     End Sub End Class Runtime: Click here if you like this article.
Sumber http://rani-irsan.blogspot.com

You Might Also Like:

Comment Policy: Silahkan tuliskan komentar Anda yang sesuai dengan topik postingan halaman ini. Komentar yang berisi tautan tidak akan ditampilkan sebelum disetujui.
Buka Komentar