vb小白,求高人指点!

Angusrun 2019-03-19 12:09:53
输入月日年,要求用weekday输出该日期的星期,求高人指点,谢了。
...全文
54 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
milaoshu1020 2019-03-19
  • 打赏
  • 举报
回复
试试这段代码:
    Dim datInput As Date
datInput = InputBox("请输入日期(月-日-年):")

Dim intResult As Integer
intResult = Weekday(datInput, vbMonday)

MsgBox intResult
Angusrun 2019-03-19
  • 打赏
  • 举报
回复
引用 3 楼 milaoshu1020的回复:
代码:
Option Explicit

Private 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
非常感谢,可以运行了,谢谢大佬!
milaoshu1020 2019-03-19
  • 打赏
  • 举报
回复
代码:
Option Explicit

Private 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
Angusrun 2019-03-19
  • 打赏
  • 举报
回复
弹出with 或对象变量未设置 那如果月日年用text输入该怎么写?

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧