计算出生日期那天是星期几

来源:互联网 发布:ubuntu 移除ppa 编辑:程序博客网 时间:2024/04/28 08:21

Private Sub Command1_Click()

  Dimyear As Integer

  Dimmonth As Integer

  Dimday As Integer

  Dimweekofday As Byte

  Dimbirthday As Date

year = Int(Val(Text1.Text))

month = Int(Val(Text2.Text))

day = Int(Val(Text3.Text))

birthday = DateSerial(year, month, day)

 

weekofday = Weekday(birthday)

Label6.Caption = WeekdayName(weekofday)

 

End Sub

 

Function myweekdayname(weekofday AsInteger) As String

 Select Case weekofday

    case1

    myweekdayname "星期日"

    case2

    myweekdayname "星期一"

    case3

    myweekdayname "星期二"

    case4

    myweekdayname "星期三"

    case5

    myweekdayname "星期四"

    case6

    myweekdayname "星期五"

    Case7

    myweekdayname "星期六"

End Select

 

End Function