网站建设资讯

NEWS

网站建设资讯

vb.net取月份的简单介绍

怎么在VB.NET中,提取系统日期中的后的 月和日 的位数

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

专注于为中小企业提供成都网站设计、做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业波密免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了成百上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

Dim a As Short = Date.Now.Month

Dim b As Short = Date.Now.Day

MessageBox.Show(a)

MessageBox.Show(b)

End Sub

上面是获取月份以及天数

'======================

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim a As Short = Date.Now.Month

Dim b As Short = Date.Now.Day

Dim c, d As String

If a 0 AndAlso a 10 Then

c = "1位数"

Else

c = "2位数"

End If

If b 0 AndAlso b 10 Then

d = "1位数"

Else

d = "2位数"

End If

MessageBox.Show(c)

MessageBox.Show(d)

End Sub

这个是获取位数的

vb.net中如何获取当前日期所在星期的星期一的具体年月日

Dim ThisDay As String = Format(Now, "yyyy-MM-dd") '获得当前日期字符串

Dim ThisDateTime As DateTime = Convert.ToDateTime(ThisDay) '当前日期转换成DateTime

Dim ThisWeekDay As Integer = ThisDateTime.DayOfWeek '获得当前日期是星期几

Dim differadd As Integer = 1 - ThisWeekDay '相差的天数(星期1与当前星期几相差的天数)

Dim MyAdd As New TimeSpan(differadd, 0, 0, 0)

Dim MyYear As Integer = Format(Now, "yyyy") '获取当前日期的年份

Dim MyMonth As Integer = Format(Now, "MM") '获取当前日期的月份

Dim MyDay As Integer = Format(Now, "dd") '获取当前日期是几号

Dim MyToday As DateTime = New DateTime(MyYear, MyMonth, MyDay)

Dim Yourday As DateTime = MyToday.Add(MyAdd)

MsgBox("本周星期一的日期是:" Yourday)

vb.net中怎么获取日期中的年月日时分秒

Dim ThisDay As String = Format(Now, "yyyy-MM-dd") '获得当前日期字符串

Dim ThisDateTime As DateTime = Convert.ToDateTime(ThisDay) '当前日期转换成DateTime

Dim ThisWeekDay As Integer = ThisDateTime.DayOfWeek '获得当前日期是星期几

Dim differadd As Integer = 1 - ThisWeekDay '相差的天数(星期1与当前星期几相差的天数)

Dim MyAdd As New TimeSpan(differadd, 0, 0, 0)

Dim MyYear As Integer = Format(Now, "yyyy") '获取当前日期的年份

Dim MyMonth As Integer = Format(Now, "MM") '获取当前日期的月份

Dim MyDay As Integer = Format(Now, "dd") '获取当前日期是几号

Dim MyToday As DateTime = New DateTime(MyYear, MyMonth, MyDay)

Dim Yourday As DateTime = MyToday.Add(MyAdd)

MsgBox("本周星期一的日期是:" Yourday)


分享名称:vb.net取月份的简单介绍
文章链接:http://cdweb.net/article/docoipi.html