试试这段代码: Dim datInput As Date datInput = InputBox("请输入日期(月-日-年):")
Dim intResult As Integer intResult = Weekday(datInput, vbMonday)
MsgBox intResult
弹出with 或对象变量未设置 那如果月日年用text输入该怎么写?
代码: Option ExplicitPrivate Sub Command1_Click() If Not IsDate(Text1.Text) Then MsgBox "输入错误!" Else Dim intResult As Integer intResult = Weekday(Text1, vbMonday)
MsgBox intResult End If End Sub 演示:下载地址: 链接:https://pan.baidu.com/s/1vvPgjbDKRelwnBVO8TR2MA 提取码:3u1i
Dim datInput As Date
datInput = InputBox("请输入日期(月-日-年):")
Dim intResult As Integer
intResult = Weekday(datInput, vbMonday)
MsgBox intResult
那如果月日年用text输入该怎么写?
Option ExplicitPrivate Sub Command1_Click()
If Not IsDate(Text1.Text) Then
MsgBox "输入错误!"
Else
Dim intResult As Integer
intResult = Weekday(Text1, vbMonday)
MsgBox intResult
End If
End Sub
演示:下载地址:
链接:https://pan.baidu.com/s/1vvPgjbDKRelwnBVO8TR2MA
提取码:3u1i