如何在'startdate'添加几天后找到'enddate' [英] how to find 'enddate' after adding some days to a 'startdate'

查看:107
本文介绍了如何在'startdate'添加几天后找到'enddate'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个文本框。在TB1中,我输入''startdate''。在Tb2中,我输入20天。在TB3中我想要结果''enddate''。我使用1个日期时间变量命名为''v_startdate'',变量''v_adddays''来自TB2的20天和一个字符串变量''v_expdt''并尝试使用以下代码。它没有用。可以有人指导吗?



string v_expdt = v_adddays + v_startdt;

I have three textboxes. In TB1 I enter ''startdate''. In Tb2 I enter 20 days. In TB3 I want the result ''enddate''. I used 1 datetime variables named as ''v_startdate'',variable ''v_adddays'' for 20 days from TB2 and a string variable ''v_expdt'' and tried with the following code. It is not working .Can anyone guide?

string v_expdt = v_adddays + v_startdt;

推荐答案

1 )我不会使用Textbox而是使用DateTimePickers来获取日期信息。

2)使用NumberUpDown来增加天数。



所以你有3个控件



1) I would not use Textboxes instead use DateTimePickers for the date information.
2) Use a NumberUpDown for the number of days to increment by.

So you have 3 controls

DateTimePicker StartDate
DateTimePicker EndDate
NumberUpDown   NoOfDays

EndDate.Value = StartDate.Value.AddDays(NoOfDays.Value);





这样的事情应该可以胜任。



您可以在numberupdown控件的ValueChanged事件中进行一些处理,以便在更改值时EndDate会自动更新。



Something like that should do the job.

You could put some handling in the ValueChanged event of the numberupdown control so that when the value is altered EndDate is automatically updated.


v_expdt = v_startdt.AddDays(v_adddays).ToString();


这篇关于如何在'startdate'添加几天后找到'enddate'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆