三九宝宝网宝宝百科宝宝知识

求写一道VBA语句的题判断你的生日是一个星期中的第几天并且输

01月07日 编辑 39baobao.com

Sub 我的生日()

'在A1单元格输入生日日期,格式为:2000/10/25

sr = Range("A1")

If sr <> "" Then

week = Weekday(sr, 2)

If week = 1 Then wek = "一"

If week = 2 Then wek = "二"

If week = 3 Then wek = "三"

If week = 4 Then wek = "四"

If week = 5 Then wek = "五"

If week = 6 Then wek = "六"

If week = 7 Then wek = "日"

MsgBox sr & " (星期" & wek & ")" & Chr(13) & "是我的生日"

Else

MsgBox "请在A1单元格中输入你的生日日期"

End If

End Sub

推荐阅读
图文推荐