DateAdd()

DateAdd function is coded in this project, i submit it in the forum, any remarks or improvement are welcome.

link text

I will have to read about Variant, I don’t understand how that work and why you use it in your program.

You use a ComboBox for the values, but the ComboBox let’s you put other values. If you want to limit the user input to your values you can change that to PopupMenu, depending of what you want.

I don’t know how to explain this, I hope you understand. You define ‘future’ as New Date, then send it to your Method as ‘dt’ but that is not used when you add something to it, you use ‘datead’ as New Date. You don’t need ‘datead’ you can use ‘dt’ directly if you define it as date instead of variant and change the PushButton1 Action to:

 TFfuture.text = DateAdd(interval,num,future)

You can also use Select Case instead of If-Elseif

Because you want to put the result of DateAdd to a TextField you can return String instead of Variant, you remove dt= line from DateAdd and change Return to:

Return dt.SQLDateTime

[quote=409946:@Alberto De Poo]I will have to read about Variant, I don’t understand how that work and why you use it in your program.

You use a ComboBox for the values, but the ComboBox let’s you put other values. If you want to limit the user input to your values you can change that to PopupMenu, depending of what you want.

I don’t know how to explain this, I hope you understand. You define ‘future’ as New Date, then send it to your Method as ‘dt’ but that is not used when you add something to it, you use ‘datead’ as New Date. You don’t need ‘datead’ you can use ‘dt’ directly if you define it as date instead of variant and change the PushButton1 Action to:

 TFfuture.text = DateAdd(interval,num,future)

You can also use Select Case instead of If-Elseif

Because you want to put the result of DateAdd to a TextField you can return String instead of Variant, you remove dt= line from DateAdd and change Return to:

Return dt.SQLDateTime

cbobox is used only for test it’s more simple to change the interval and introduce values, (interface is only for the example).
Thank’s for your remark Alberto.