Please help. I have a form with textbox 3 for the start date of the installments and another textbox 6 for the payment period for one installment per month, and the number of 15 textboxes from H1 to H15. It is required to modify this code so that the number of months increases from the date of the installment, as it increases the number of days.
For i = 1 To 15
If i = 1 Then
Me("h" & i) = TextBox3.Text
Else
Me("h" & i) = Format(CDate(Me.TextBox3.Value) i - 1, "dd/mm/yyyy")
End If
Next i
It is required to modify this code so that the number of months increases from the date of the installment, as it increases the number of days. enter image description here
CodePudding user response:
You're going to need to use dateadd.
For i = 1 To 15
If i = 1 Then
Me("h" & i) = TextBox3.Text
Else
Me("h" & i) = Format(DateAdd("m", i-1, CDate(Me.TextBox3.Value)), "dd/mm/yyyy")
End If
Next i
CodePudding user response:
I can't comment yet (lack reputation), otherwise i would, you said that the "step" suggestion by Forward Ed is not working, is the value in textbox6 a number?? if for instance its "6 months" that won't work, if its a number you could check if its formatted as a number, in the second image it says 3, but i may be a string "3", you should check that, if it's a string, use CInt(textbox6.value)