输入月日年,要求用weekday输出该日期的星期,求高人指点,谢了。

解决方案 »

  1.   

    试试这段代码:
        Dim datInput As Date
        datInput = InputBox("请输入日期(月-日-年):")
        
        Dim intResult As Integer
        intResult = Weekday(datInput, vbMonday)
        
        MsgBox intResult
      

  2.   

    弹出with 或对象变量未设置
    那如果月日年用text输入该怎么写?
      

  3.   

    代码:
    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