十年網站開發(fā)經驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網站問題一站解決
用日期函數(shù)day()可獲得當前日期,time()可獲得當前系統(tǒng)時間.
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供東光網站建設、東光做網站、東光網站設計、東光網站制作等企業(yè)網站建設、網頁設計與制作、東光企業(yè)網站模板建站服務,十余年東光做網站經驗,不只是建網站,更提供有價值的思路和整體網絡服務。
dim CurDay as string
dim CurTime as string
curday=day()
curtime=time()
Label1.Caption = Date
就能在Label16顯示當前日期
now 這個函數(shù)可以獲得當前系統(tǒng)時間(包括年月日,小時分鐘秒)
而
year()
month()
day()
等等則可以從now返回的值中分別提取年,月,日的信息
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
上面是獲取月份以及天數(shù)
'======================
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位數(shù)"
Else
c = "2位數(shù)"
End If
If b 0 AndAlso b 10 Then
d = "1位數(shù)"
Else
d = "2位數(shù)"
End If
MessageBox.Show(c)
MessageBox.Show(d)
End Sub
這個是獲取位數(shù)的
其實電腦中的日期格式是Date類型,你所說的"yyyy-M-d“還是“yyyy/M/d"都是其轉換為字符串以后顯示的方式,你可以用Format函數(shù)將Date類型轉換為你希望顯示的任何形式,例如:
Format(DateTimePicker1.Value, "yyyy-MM-dd") '2014-08-30
Format(DateAndTime.Now, "yyyy-M-d") '2014-8-30
Format(DateTimePicker1.Value, "Long Date") '2014年8月30日