next payment due date from a current date to next month,quaterly,half-yearly & yearly

master_2013

Active member
Joined
Jul 8, 2013
Messages
41
Programming Experience
Beginner
next payment due date from a current date to next month,quaterly,half-yearly & yearly

sir i want to get next payment due date from a current date to next month,quarterly,half-yearly & yearly please help me on this using vb.net please help me on this
 
Hi,

Have a look at the AddMonths and AddYears methods of the DateTime structure:-

DateTime.AddMonths Method (System)

Hope that helps.

Cheers,

Ian




here is my code what i written but i getting odd due date

    Private Sub Radiofeesquarterly_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radiofeesquarterly.CheckedChanged
        feesmode.Text = "Quarterly"
        If ComboBox1.Text = "" Then
            MsgBox("Please select member!", MsgBoxStyle.Exclamation, Me.Text)
            Label12.Visible = False
        Else
            Label12.Visible = True
            If DateTimePicker3.Value.Month = 12 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 9 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text
            ElseIf DateTimePicker3.Value.Month = 11 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 9 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text
            ElseIf DateTimePicker3.Value.Month = 10 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 9 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text
            Else
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month + 3 & "-" & DateTimePicker3.Value.Year
                Label12.Text = DateTimePicker2.Text
            End If
        End If
    End Sub

    Private Sub Radiofeeshalfyearly_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radiofeeshalfyearly.CheckedChanged
        feesmode.Text = "Half Yearly"
        If ComboBox1.Text = "" Then
            MsgBox("Please select member!", MsgBoxStyle.Exclamation, Me.Text)
            Label12.Visible = False
        Else
            Label12.Visible = True
            If DateTimePicker3.Value.Month = 12 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 6 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text

            ElseIf DateTimePicker3.Value.Month = 11 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 6 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text

            ElseIf DateTimePicker3.Value.Month = 10 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 6 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text

            ElseIf DateTimePicker3.Value.Month = 9 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 6 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text

            ElseIf DateTimePicker3.Value.Month = 8 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 6 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text

            ElseIf DateTimePicker3.Value.Month = 7 Then
                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month - 6 & "-" & DateTimePicker3.Value.Year + 1
                Label12.Text = DateTimePicker2.Text

            Else

                DateTimePicker2.Text = "1-" & DateTimePicker3.Value.Month + 6 & "-" & DateTimePicker3.Value.Year
                Label12.Text = DateTimePicker2.Text
            End If
        End If
    End Sub
 

Attachments

  • Untitled1.jpg
    Untitled1.jpg
    73.9 KB · Views: 37
Last edited by a moderator:
You were told to use the DateTime.AddMonths method and you're not, so why would you expect it to work? If you don't follow instructions then you're not likely to get the desired result.

A DateTimePicker has a Value that returns the selected DateTime. You can call the AddMonths method of that DateTime to get another DateTime that is the specified number of months later. Do that and it will work; don't and it won't.
 
so sorry for this sir i will follow your answer

You were told to use the DateTime.AddMonths method and you're not, so why would you expect it to work? If you don't follow instructions then you're not likely to get the desired result.

A DateTimePicker has a Value that returns the selected DateTime. You can call the AddMonths method of that DateTime to get another DateTime that is the specified number of months later. Do that and it will work; don't and it won't.

i am really really sorry for this i will follow your and trying these code as you mentioned if not works i will ask you thanks for ypor support
 
Can u please explain me with a example if i paid a fees on date 1-jan-2012 and my next due is in 1-feb-2012 please3 help me
 
sir i tried these examples its working fine in text box but when i used to calculate the next month,quarter,half year & yearly it shows back date from the date o admission help me ????? here is my code


Private Sub Radiofeesquarterly_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radiofeesquarterly.CheckedChanged
feesmode.Text = "Quarterly"
Dim bd As Date = Datetimeadmin.Text
If Datetimeadmin.Text = Now() Then
DateTimePicker2.Text = bd.AddMonths(3)
End If

Admission Date is 18-10-2013 due date showing 03-06-2012 what i am doing wrong
 
You're using Strings all over the place there when you should be using Dates exclusively. Presumably 'Datetimeadmin' and 'DateTimePicker2' are DateTimePickers. If they're not, they should be. Also, if you're not working with times then you shouldn't be using Now. That code should most likely be:
VB.NET:
Dim bd As Date = Datetimeadmin.Value.Date

If bd = Date.Today Then
    DateTimePicker2.Value = bd.AddMonths(3)
End If
I'm not really sure why you're comparing to the current date to begin with but, as you haven't provided a coherent explanation, we can only guess.
 
it works like a charm thank you very very much sir

one more question how to make auto generate receipt no and invoice number in data bindings
 
Last edited:
it works like a charm thank you very very much sir

one more question how to make auto generate receipt no and invoice number in data bindings

That's nothing to do with the topic of this thread. Please start a new thread for a new topic.
 
Back
Top