天天看点

计算出生那天是星期几

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