两次之间的周数

编程入门 行业动态 更新时间:2024-10-28 08:17:57
本文介绍了两次之间的周数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我必须下拉列表.每个下拉列表都包含星期和年份的值(例如1-2006).我要计算周数,并且要在vb的文本框中显示该计数,同时页面加载下拉列表应自动显示当前的周和年. (例如,本周是第27周和2011年.) 因此,在页面加载时,两个下拉列表均应显示27-2011. 怎么做. 1)我不希望统计在下拉菜单之间的周数.(1-2006至5-2007)1和5是对应年份的周. 2)默认情况下,我要在页面加载时的下拉列表中显示当前星期. 我的周从星期一到星期日开始. 预先感谢您的帮助. 问候, Ganesh.S

Hi All, I have to dropdown. Each dropdown contain week and year values (Ex.1-2006). I want to count the weeks and the count want to display in textboxes in vb and also while pageload dropdown should automatically display the current week and year. (Ex.this week is 27th week and 2011 year.) So both dropdown should display 27-2011 while page load. How to do this. 1) I want to count no of weeks in between seleted dropdown.(1-2006 to 5-2007) 1 and 5 is the week for the corresponding year. 2) I want to display the current week is by default in the dropdown while page load. My weeks starts from Monday to sunday. Thanks in advance for the help. Regards, Ganesh.S

推荐答案

我不知道为什么我要回答这个问题! :doh: 你甚至尝试过吗? I don''t know why I am answering this!! :doh: Did you even try? Dim result as Integer Dim s1 As String = "5-2007" Dim s2 As String = "42-2011" If (Convert.ToInt16(s2.Split("-")(1)) < Convert.ToInt16(s1.Split("-")(1))) _ OrElse ((Convert.ToInt16(s2.Split("-")(1)) = Convert.ToInt16(s1.Split("-")(1))) And (Convert.ToInt16(s2.Split("-")(0)) <= Convert.ToInt16(s1.Split("-")(0)))) Then ''error ElseIf (Convert.ToInt16(s2.Split("-")(1)) = Convert.ToInt16(s1.Split("-")(1))) Then result=MsgBox(Convert.ToInt16(s2.Split("-")(0)) - Convert.ToInt16(s1.Split("-")(0))) Else Dim weeks1 As Integer = (52 - Convert.ToInt16(s1.Split("-")(0))) Dim weeks2 As Integer = (Convert.ToInt16(s2.Split("-")(0))) result=(52 * (Convert.ToInt16(s2.Split("-")(1)) - Convert.ToInt16(s1.Split("-")(1)) - 1) + weeks1 + weeks2) End If ''result is the weeks

Dim dfi As Globalization.DateTimeFormatInfo = Globalization.DateTimeFormatInfo.CurrentInfo Dim cal As Globalization.Calendar = dfi.Calendar ''Your current value should be ''(cal.GetWeekOfYear(Today, Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday) & "-" & Today.Year)

这是逻辑,为什么您需要帮助. This is logic, why do u need help.

您也许可以使用.NET的时间段库 [ ^ ].您可能需要在此处进行一些修改,但这可能会一直为您提供帮助. You may be able to use something from Time Period Library for .NET[^]. You would likely have to modify something here, but it could help you along the way.

更多推荐

两次之间的周数

本文发布于:2023-10-27 03:53:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532231.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两次

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!