VB.net请帮助我 [英] VB.net please help me

查看:78
本文介绍了VB.net请帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要代码来计算vb.net中年,月和日中两个日期之间的持续时间,并将1991年5月14日转换为1991年5月14日
谢谢

i need code in Calculating Duration Between Two Dates in Years, Months and Days in vb.net and converting 5-14-1991 to may 14,1991
thanks

推荐答案

这样简单:

结构System.DateTime具有定义的"-"(减法运算符);其返回类型为System.TimeSpan.

请参阅 http://msdn.microsoft.com/en-us/library/system.datetime.aspx [^ ] .

这应该足够了.

不要转换"任何东西.您需要使用System.DateTime结构,而不是它的字符串表示形式.您仅应在屏幕上显示时间数据时创建字符串表示形式.在这种情况下,您只需要根据线程的当前UI文化或仅自定义适当的格式即可.

请参阅此处的System.DateTime: http://msdn.microsoft.com/en-us/library/system.datetime.aspx [^ ].
有关格式,请参见:
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx [ ^ ].

—SA
This as simple as this:

The structure System.DateTime has "-" (subtraction operator) defined; its return type is System.TimeSpan.

See http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].

This should be more then enough.

Do not "convert" anything. You need to work with System.DateTime structure, not with string representation of it. You only should create string representation when you show time data on screen. In this case you just need to appropriate format, based on current UI culture of your thread or just custom.

See System.DateTime here: http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].
For formatting, see:
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^].

—SA


这篇关于VB.net请帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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